C# 随机声音 调用Win32类库
C# 随机声音 调用Win32类库 QQ:292258449 class Program { /// /// 调用Win32类库kernel32.dll /// /// 声音频率 /// 声音持续时间 /// [DllImport("kernel32.dll")] public static extern bool Beep(int frequency, int duration); static void Main(string[] args) { //随机数生成器 Random random = new Random(); //调用100次,产生随机100种声音 for (int i = 0; i < 100; i++) { Beep(random.Next(10000), 300);// 调用Win32类库kernel32.dll } } } [DllImport("kernel32.dll")] public static extern bool Beep(int frequency, int duration); static void Main(string[] args) { //随机数生成器 Random random = new Random(); //调用100次,产生随机100种声音 for (int i = 0; i < 100; i++) { Beep(random.Next(10000), 300);// 调用Win32类库kernel32.dll } } }
用户评论