Beep Function

Generates simple tones on the speaker. The function is synchronous; it performs an alertable wait and does not return control to its caller until the sound finishes.

Syntax

C++
BOOL WINAPI Beep(
  __in  DWORD dwFreq,
  __in  DWORD dwDuration
);

Parameters

dwFreq [in]

The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).

dwDuration [in]

The duration of the sound, in milliseconds.

Return Value

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.

Remarks

Muting and volume controls have no effect on Beep; you will still hear the tone. To silence the tone, use the following commands:

net stop beep

sc config beep start= disabled

Terminal Services:  The beep is redirected to the client.
Windows Vista x64 and Windows XP 64-Bit Edition:  This function is not supported.

Examples

The following example demonstrates the use of this function.

Beep( 750, 300 );

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll

See Also

Error Handling Functions
MessageBeep
Notifying the User

Send comments about this topic to Microsoft

Build date: 11/12/2009

Tags :


Community Content

dmex
vb.net syntax
<DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function Beep(ByVal frequency As Integer, ByVal duration As Integer) As Boolean
End Function
Tags : vb.net syntax

dmex
C# syntax
[DllImport("kernel32.dll", SetLastError=true)]
public static extern bool Beep(int frequency, int duration);
Tags : c# syntax

Stanley Roark
Beep
As a c++ developer I really do miss the Beep(dwFrequency, dwDuration) function. It was so handy,
not least as a primary debug tool. I do hope that ms has considered putting it back into 7!


---
This is also broken in Windows 7 and also Server 2008(R2). We use this feature to find machines in the server farm.

Srdjan Obucina
Beep
On Windows 7 Beep does not make sound on a motherboard speaker, but on a sound card. I am using Beep as a warning indicator on a machines with no speakers. I really miss this feature. Please consider making it work on a motherboard speaker.
Tags :

Page view tracker