除非自己写!贴一个英国人写的!
一个由英国人John Atkins用汇编写的操纵底层资源的发音函数:
function _GetPort(address:word):word;//获取端口
var
bValue: byte;
begin
asm
mov dx, address
in al, dx
mov bValue, al
end;
Result := bValue;
end;
procedure _SetPort(address, Value:Word);//设置端口
var
bValue: byte;
begin
bValue := Trunc(Value and 255);
asm
mov dx, address
mov al, bValue
out dx, al
end;
end;
procedure StartBeep(Freq : Word);//开始发音,Freq为频率
var
B: Byte;
begin
if Freq >18 then
begin
Freq := Word(1193181 div LongInt(Freq));
B := Byte(_GetPort($61));
if (B and 3) = 0 then
begin
_SetPort($61, Word(B or 3));
_SetPort($43, $B6);
end;
_SetPort($42, Freq);
_SetPort($42, Freq shr 8);
end;
end;
procedure StopBeep;//停止发音
var
Value: Word;
begin
value := _GetPort($61) and $FC;
_SetPort($61, Value);
end;
有了上述发音函数后,就可以轻松地写出在win9x环境下让主板喇叭奏乐报时的程序了.