29.24 How do I beep the computer's speaker in a Windows Form application?


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();



© 2001-2010 Copyright Syncfusion Inc. All rights reserved.  |  Privacy Policy  |  Contact  |  Sitemap