;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfBeep (intFrequency, intDuration) DllCall ("KERNEL32.DLL", long : "Beep", long : intFrequency, long : intDuration) ;.......................................................................................................................................... ; 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. ; ; Copy Code Beep( 750, 300 ); ; ; Requirements ; Minimum supported client Windows 2000 Professional ; Minimum supported server Windows 2000 Server ; Header Winbase.h (include Windows.h) ; Library Kernel32.lib ; DLL ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ; Test. For intRndBeepLoop = 1 To 100 intFrequency = Random (5000) intDuration = Random (80) udfBeep (intFrequency, intDuration) Next intRndBeepLoop TimeDelay (1) udfBeep (1000, 70) udfBeep (400, 70) udfBeep (1000, 70) udfBeep (400, 70) udfBeep (1340, 200) TimeDelay (1) For intBeepFreq = 100 To 2000 By 50 udfBeep (intBeepFreq, 1) Next udfBeep (2000, 80) For intBeepFreq = 1000 To 1800 By 50 udfBeep (intBeepFreq, 5) Next udfBeep (1800, 50) For intLoop = 1 To 3 For intBeepFreq = 1800 To 400 By -50 udfBeep (intBeepFreq, 8) Next Next Exit