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

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客园 - 海盗

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方法,播放音乐
    }

  }
  
}