void __fastcall Tfrmmain::Bell(int freq,int delay)
{
if (!GetVersion() < 0x80000000) //判斷操作系統,<0x80000000 為98
{
const int scale = 1193180;
WORD freqTemp = (WORD)(scale/freq);
asm
{
in al,61h;
or al,3;
out 61h,al;
mov al,0xb6;
out 43h,al;
mov ax,freqTemp;
out 42h,al;
mov al,ah;
out 42h,al;
}
Sleep ( delay ) ;
asm
{
in al,0x61;
and al,0xfc;
out 0x61,al;
}
}
else
{Beep(freq,delay);}
}
//-------------------------------------