C#使Pc喇叭发声

来源:互联网 发布:爱因斯坦厉害知乎 编辑:程序博客网 时间:2024/04/28 02:40
using  System; 
using  System.Runtime.InteropServices;  //这行一定要加
class  test 

           [DllImport("kernel32.dll")] 
           private  static  extern  int  Beep(int  dwFreq  ,int  dwDuration)  ; 
 
           public  static  void  Main() 
           { 
                       int  a=0X7FF;  //发生频率(Hz)
                       int  b=1000;  //持续时间(毫秒)
                       Beep(a,b); 
                   } 
}