There is no Windows Form function to beep your computer’s speaker. But you can just invoke the Win32 API MessageBeep.
using System.Runtime.InteropServices;
...
[DllImport('user32.dll')]
public static extern int MessageBeep(uint n);
private void button2_Click(object sender, System.EventArgs e)
{
MessageBeep(0x0);
}
Another method (suggested by msauper@sauper.com on microsoft.public.dotnet.framework.windowsforms)
Reference the VB.NET runtime support and just use the Beep() method.
The method is in:
Microsoft.Visual Basic.NET Runtime
The method is:
Microsoft.VisualBasic.Interaction.Beep();
Share with