首页 > 开发 > 综合 > 正文

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

2024-07-21 02:26:37
字体:
来源:转载
供稿:网友


<一>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);

 


 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表