/// <param name="iFrequency">聲音頻率(從37Hz到32767Hz)。在windows95中忽略</param>
/// <param name="iDuration">聲音的持續時間,以毫秒為單位。</param>
[DllImport("Kernel32.dll")] //引入命名空間 using System.Runtime.InteropServices;
public static extern bool Beep(int frequency, int duration);
這個是妳自定義的聲音,可以在妳點擊按鈕時調用Beep(800,200);該函數
又例如:
public enum MessageBeepType
{
Default = -1,
Ok = 0x00000000,
Error = 0x00000010,
Question = 0x00000020,
Warning = 0x00000030,
Information = 0x00000040
}
[DllImport("user32.dll", SetLastError = true)]
public static extern bool MessageBeep(MessageBeepType type);
這個是系統的聲音,可以在妳點擊按鈕時調用MessageBeep(MessageBeepType.Ok);該函數
希望對妳有幫助