Live Chat Icon For mobile
Live Chat Icon

How do I beep the computer’s speaker in a Windows Form application

Platform: WinForms| Category: Tips

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

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.