當前位置:編程學習大全網 - 網站源碼 - C# Winform 程序 使用電腦自帶的喇叭,輸出報警聲?

C# Winform 程序 使用電腦自帶的喇叭,輸出報警聲?

妳可以使用系統自帶的聲音,例如

/// <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);該函數

希望對妳有幫助

  • 上一篇:Java當前源代碼
  • 下一篇:如何打開《植物大戰僵屍2國際版》(V4.5.2)的obb數據包?能解包和打包就行了,網上說的直接用
  • copyright 2024編程學習大全網