Click to Rate and Give Feedback
MSDN
MSDN Library
Diagnostics
Error Handling
 Beep Function

  Switch on low bandwidth view
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: 7/2/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
vb.net syntax      dmex   |   Edit   |   Show History
<DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function Beep(ByVal frequency As Integer, ByVal duration As Integer) As Boolean
End Function
Flag as ContentBug
C# syntax      dmex   |   Edit   |   Show History
[DllImport("kernel32.dll", SetLastError=true)]
public static extern bool Beep(int frequency, int duration);
Tags What's this?: c# (x) syntax (x) Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker