16,467
社区成员
发帖
与我相关
我的任务
分享
/***************************************************************************
* Function Name : playWarnningSound
* Description : PC 喇叭或者扬声器报警
* Return : -
* Parameters : delay - 持续时间
: freq - 频率
* Author : Behard
* Date : 2002/05/28
***************************************************************************/
void playWarnningSound ( int delay , int freq )
{
if ( Form1->blNT ) //NT 2000 XP
{ Beep ( freq, delay ); return; }
const int scale = 1193180 ;
WORD freqTemp = (WORD)(scale/freq) ;
asm //发声 9x
{
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;
}
}