Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than kernel32, prefix the name with the module name and a period.
Declare Function Beep Lib "kernel32.dll" (dwFreq As Integer, _
dwDuration As Integer) As Boolean
Parameter Information:
dwFreq
Windows NT:
Specifies the frequency, in hertz, of the sound. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).
Windows 95:
The parameter is ignored.
dwDuration
Windows NT:
Specifies the duration, in milliseconds, of the sound.
Windows 95:
The parameter is ignored.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Notes:
Unlike MessageBeep, this function is synchronous. (It doesn't return control to its caller until the sound finishes.)
Tips & Tricks:
Please add some sample code!
VB.NET Sample Code:
The following sample plays the PC speaker in a series of ascending frequencies:
''This Sample added by Christopher Pietschmann, MCSD, MCAD
Declare Function Beep Lib "kernel32.dll" (ByVal dwFreq As Integer, _
ByVal dwDuration As Integer) As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim I As Integer
For I = 900 To 1400
Beep(I, 5)
Next
End Sub
C# Sample Code:
The following sample plays the PC speaker in a series of ascending frequencies:
using System;
using System.Runtime.InteropServices;
static void Main()
{
Console.WriteLine("Testing PC speaker...");
for (uint i = 100; i <= 20000; i++)
{
Beep(i, 5);
}
Console.WriteLine("Testing complete.");
}
}
Added by David C. Carachi
Alternative Managed API:
System.Console.Beep, coming in v2.0 (Whidbey) of the .NET Framework
Plays a waveform sound.
7/1/2010 10:25:43 AM - -92.251.8.36
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).