这两个函数可以:
procedure sound(mhz : integer);
{mhz = the frequency of the pc speaker}
var
count : word;
oldport,
newport : byte;
begin
count := 1193280 div mhz;
asm
mov al,$b6
out $43,al
mov ax,count
out $42,al
mov al,ah
out $42,al
mov al,3
out $61,al
end;
end;
procedure nosound;
{turn off the pc speaker}
begin
asm
mov al,0
out $61,al
end;
end;