Question and Answer Database FAQ1838D.txt Timed beeps from the PC speaker Category :Windows API Platform :All Product :All 32 bit Question: How can I beep the PC Speaker several times in a row, and have a small delay between beeps that is reliable across different machines with different clock speeds? Answer: The following demonstrates using a delay function that can be used to beep the PC speaker. Example: procedure Delay(ms : longint); {$IFNDEF WIN32} var TheTime : LongInt; {$ENDIF} begin {$IFDEF WIN32} Sleep(ms); {$ELSE} TheTime := GetTickCount + ms; while GetTickCount < TheTime do Application.ProcessMessages; {$ENDIF} end; procedure TForm1.Button1Click(Sender: TObject); begin MessageBeep(word(-1)); Delay(200); MessageBeep(word(-1)); Delay(200); MessageBeep(word(-1)); end; 7/16/98 4:31:28 PM
Last Modified: 01-SEP-99