//1. [DllImport("Kernel32.dll")] //引入命名空間 using System.Runtime.InteropServices; public static extern bool Beep(int frequency, int duration);// 第一個參數是指頻率的高低,越大越高,第二個參數是指響的時間多 Beep(500, 700); //2. [DllImport("winmm.dll")] public static extern bool PlaySound(String Filename, int Mod, int Flags); PlaySound(@"C:\Windows\media\Windows Proximity Notification.wav", 0, 1);
