您的位置:首页 > 编程语言 > C#

C#调用声音函数(PlaySound,Beep,MessageBeep等)

2010-04-22 10:33 357 查看
[转载]C#调用声音函数(PlaySound,Beep,MessageBeep等)
 <一>Visual Basic Beep()
  1.使用Visual Basic Beep函数;添加引用 Miscorsoft Visual Basic Runtime
  2.调用 Interaction.Beep();
  <二>使用MessageBeep(unit uType):需添加 using System.Runtime.InteropServices;
  public const int MB_ICONEXCLAMATION = 48;
   [DllImport("user32.dll")]
   public static extern bool MessageBeep(uint uType);
  MessageBeep( MB_ICONEXCLAMATION );
  <三>调用Beep(Int freq,int duration)函数
   [DllImport("kernel32.dll")]
   public static extern bool Beep(int freq,int duration);
  Beep(800,300);
  <四>调用PlaySound(string pszSound,int hmod,int fdwSound)
   [DllImport("winmm.dll")]
   public static extern bool PlaySound(string pszSound,int hmod,int fdwSound);
   public const int SND_FILENAME = 0x00020000;
   public const int SND_ASYNC = 0x0001;
  PlaySound("提示时奏幻想空间.WAV",0,SND_ASYNC|SND_FILENAME);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: