Prøv den her den virker under alle windows versioner :
Unit Bleeper;
Interface
Procedure ShutUp; Procedure DoBleep (Freq : Word; MSecs : LongInt); { Duration of -1 means bleep until the next bleep sent, or ShutUp is called } Procedure BleepPause (MSecs : LongInt);
Procedure AsmShutUp;{$IFDEF WIN32}Pascal;{$ENDIF} Asm In AL, $61 And AL, $FC Out $61, AL End;
Procedure AsmBeep (Freq : Word);{$IFDEF WIN32}Pascal;{$ENDIF} Label Skip; Asm Push BX In AL, $61 Mov BL, AL And AL, 3 Jne Skip Mov AL, BL Or AL, 3 Out $61, AL Mov AL, $B6 Out $43, AL Skip: Mov AX, Freq Out $42, AL Mov AL, AH Out $42, AL Pop BX End;
Procedure HardBleep (Freq : Word; MSecs : LongInt); Const HiValue = {$IFDEF WIN32}High (DWord){$ELSE}High (LongInt){$ENDIF}; Begin If (Freq >= 20) And (Freq <= 5000) Then Begin AsmBeep (Word (1193181 Div LongInt (Freq))); If MSecs >= 0 Then Begin BleepPause (MSecs); AsmShutUp; End; End; End;
{ -- --- -- --- -- --- -- --- -- --- -- --- -- --- -- --- Procedures for you to use -- --- -- --- -- --- -- --- -- --- -- --- }
{$IFDEF WIN32} Var SysWinNT : Boolean; {$ENDIF}
Procedure BleepPause (MSecs : LongInt); Const HiValue = {$IFDEF WIN32}High (DWord){$ELSE}High (LongInt){$ENDIF}; Var iCurrTickCount, iFirstTickCount : {$IFDEF WIN32}DWord{$ELSE}LongInt{$ENDIF}; iElapTime : LongInt; Begin iFirstTickCount := GetTickCount; Repeat {$IFNDEF CONSOLE} If MSecs > 1000 Then Application.ProcessMessages; {$ENDIF} iCurrTickCount := GetTickCount; { Has GetTickCount wrapped to 0 ? } If iCurrTickCount < iFirstTickCount Then iElapTime := HiValue - iFirstTickCount + iCurrTickCount Else iElapTime := iCurrTickCount - iFirstTickCount; Until iElapTime >= MSecs; End;
Procedure DoBleep (Freq : Word; MSecs : LongInt); Begin If MSecs < -1 Then MSecs := 0;
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.