因为NT下不能直接完成I/O操作,98下的API又不具备发出特定频率声音的能力,所以分开处理
Procedure Beep(nFreq,nDura: Word);
var
VerInfo: TOSVersionInfo;
nStart: DWord;
begin
VerInfo.dwOSVersionInfoSize := SizeOf(VerInfo);
GetVersionEx(VerInfo);
if VerInfo.dwPlatformId = VER_PLATFORM_WIN32_NT then
Windows.Beep(nFreq, nDura)
else
begin
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, nFreq
out $42, al
mov AL, ah
out $42, al
pop bx
end;
nStart := GetTickCount;
repeat
Application.ProcessMessages;
Until GetTickCount > nStart + nDura;
asm
IN AL, $61
AND AL, $FC
OUT $61, AL
end;
end;
end;
封装成函数,各种操作系统系统下通用~~~
此文章由 http://www.ositren.com 收集整理 ,地址为:
http://www.ositren.com/htmls/67951.html