惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
W
WeLiveSecurity
IT之家
IT之家
A
About on SuperTechFans
B
Blog
L
LangChain Blog
H
Help Net Security
Engineering at Meta
Engineering at Meta
Recent Announcements
Recent Announcements
Google Online Security Blog
Google Online Security Blog
宝玉的分享
宝玉的分享
MyScale Blog
MyScale Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
N
News and Events Feed by Topic
Schneier on Security
Schneier on Security
GbyAI
GbyAI
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
S
SegmentFault 最新的问题
Cloudbric
Cloudbric
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Y
Y Combinator Blog
S
Security Affairs
The Last Watchdog
The Last Watchdog
H
Heimdal Security Blog
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
博客园 - 聂微东
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Privacy & Cybersecurity Law Blog
V
Visual Studio Blog
H
Hacker News: Front Page
Recorded Future
Recorded Future
Cyberwarzone
Cyberwarzone
L
Lohrmann on Cybersecurity
Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
C
Cybersecurity and Infrastructure Security Agency CISA
AWS News Blog
AWS News Blog
Jina AI
Jina AI
N
News | PayPal Newsroom
S
Schneier on Security

博客园 - 海盗

How to point your package manager to US server How to install Java in Ubuntu [Linux]Variable and Parameters in Bash - 海盗 HOWTO: Install chinese input One series article of Linux file system Reading notes of &lt;&gt; -- I <> - 海盗 - 博客园 Got two days' break New keyboard - 海盗 - 博客园 Some questions before learning ASP.net MVC framework Back again! JavaScript MD5 Encryption - 海盗 AJAX中的Back Button/Bookmarking问题和Nikhil Kothari的Atlas解决方案 My 50 favorite design resources 复杂域环境下通过.Net操作Active Directory经验点滴 IE ToolBar 关于C#中字段的初始化 关于namespace - 海盗 - 博客园 好久没来了!
C#播放音乐
海盗 · 2006-01-26 · via 博客园 - 海盗

using System;
//using System.Drawing;
using System.Collections;
using System.ComponentModel;
//using System.Windows.Forms;
//using System.Data;
using System.Runtime.InteropServices;

namespace 智能象棋游戏
{
 
/// <summary>
 
/// 用于播放音乐
 
/// </summary> 

 internal class Helpers 
 
{
     [Flags]
     
public enum PlaySoundFlags : int 
     
{
          SND_SYNC 
= 0x0000,  /* play synchronously (default) */ //同步
          SND_ASYNC = 0x0001,  /* play asynchronously */ //异步
          SND_NODEFAULT = 0x0002,  /* silence (!default) if sound not found */
          SND_MEMORY 
= 0x0004,  /* pszSound points to a memory file */
          SND_LOOP 
= 0x0008,  /* loop the sound until next sndPlaySound */
          SND_NOSTOP 
= 0x0010,  /* don't stop any currently playing sound */
          SND_NOWAIT 
= 0x00002000/* don't wait if the driver is busy */
          SND_ALIAS 
= 0x00010000/* name is a registry alias */
          SND_ALIAS_ID 
= 0x00110000/* alias is a predefined ID */
          SND_FILENAME 
= 0x00020000/* name is file name */
          SND_RESOURCE 
= 0x00040004  /* name is resource name or atom */
   }


   [DllImport(
"winmm")]
   
public static extern bool PlaySound( string szSound, IntPtr hMod, PlaySoundFlags flags );
}


 
public class Sound 
 
{
       
public static void Play( string strFileName )
      
{
   
//Helpers.PlaySound( strFileName, IntPtr.Zero, Helpers.PlaySoundFlags.SND_FILENAME |    Helpers.PlaySoundFlags.SND_ASYNC );
     switch(strFileName)
     
{
          
case "start": strFileName=@"..\..\sound\start.WAV";       break;
          
case "back": strFileName=@"..\..\sound\back.WAV";         break;
          
case "fall": strFileName=@"..\..\sound\fall.WAV";         break;    
          
case "huiqi": strFileName=@"..\..\sound\huiqi.WAV";       break;
          
case "huiqiend": strFileName=@"..\..\sound\huiqiend.WAV"break;
          
case "jiangjun": strFileName=@"..\..\sound\jiangjun.WAV"break;
          
case "kill": strFileName=@"..\..\sound\kill.WAV";         break;
          
case "win": strFileName=@"..\..\sound\win.WAV";           break;
          
case "move": strFileName=@"..\..\sound\move.WAV";         break;
          
case "hold": strFileName=@"..\..\sound\hold.WAV";         break;
          
case "no": strFileName=@"..\..\sound\no.WAV";             break;
          
case "popup": strFileName=@"..\..\sound\popup.WAV";       break;
          
case "mayfall": strFileName=@"..\..\sound\mayfall.WAV";   break;
    }

   Helpers.PlaySound(strFileName, IntPtr.Zero, Helpers.PlaySoundFlags.SND_FILENAME 
| Helpers.PlaySoundFlags.SND_ASYNC);        //调用Dll方法,播放音乐
    }

  }
  
}