MSDN里说:Beep The Beep function generates simple tones on the speaker. The function is synchronous; it does not return control to its caller until the sound finishes. BOOL Beep( DWORD dwFreq, // sound frequency DWORD dwDuration // sound duration ); Parameters dwFreq Windows NT/ 2000: [in] Specifies the frequency, in hertz, of the sound. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF). dwDuration Windows NT/ 2000: [in] Specifies the duration, in milliseconds, of the sound. Return Values If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError. Res Windows 95: The Beep function ignores the dwFreq and dwDuration parameters. On computers with a sound card, the function plays the default sound event. On computers without a sound card, the function plays the standard system beep.Requirements Windows NT/2000: Requires Windows NT 3.1 or later. Windows 95/98: Requires Windows 95 or later. Header: Declared in Winbase.h; include Windows.h. Library: Use Kernel32.lib.See Also Error Handling Overview, Error Handling Functions, MessageBeep 95以上就可以用Beep()这个函数了,长短频率随你定
你没看清楚 Res Windows 95: The Beep function ignores the dwFreq and dwDuration parameters. On computers with a sound card, the function plays the default sound event. On computers without a sound card, the function plays the standard system beep. 9x系列无法指定频率和时间
Freq=(unsigned short)(((double)frequency.QuadPart)/Freq);//counter number __asm { mov aL,0xB6 out 0x43,al mov ax,Freq out 0x42,al mov al, ah out 0x42,al in al,0x61 or al,3 out 0x61,al } }void AsmNoSound(void) { __asm { in al,0x61 and aL, 0xfc out 0x61, aL } }
The Beep function generates simple tones on the speaker. The function is synchronous; it does not return control to its caller until the sound finishes. BOOL Beep(
DWORD dwFreq, // sound frequency
DWORD dwDuration // sound duration
);
Parameters
dwFreq
Windows NT/ 2000: [in] Specifies the frequency, in hertz, of the sound. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).
dwDuration
Windows NT/ 2000: [in] Specifies the duration, in milliseconds, of the sound.
Return Values
If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError. Res
Windows 95: The Beep function ignores the dwFreq and dwDuration parameters. On computers with a sound card, the function plays the default sound event. On computers without a sound card, the function plays the standard system beep.Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.See Also
Error Handling Overview, Error Handling Functions, MessageBeep 95以上就可以用Beep()这个函数了,长短频率随你定
Res
Windows 95: The Beep function ignores the dwFreq and dwDuration parameters. On computers with a sound card, the function plays the default sound event. On computers without a sound card, the function plays the standard system beep.
9x系列无法指定频率和时间
谁能教我?可以再加分的,决不食言!
最简单也是最实用如果不想做播放器的话
waveXXX都要用到audio device,好麻烦
我只是想有那么“嘀”的一声,但不要系统的声音,真的没有简单的办法么?
直接用系统的中断
WIN2000可以用BEEP()
void AsmSound(WORD Freq)
{
LARGE_INTEGER frequency;
QueryPerformanceFrequency(&frequency);
Freq=(unsigned short)(((double)frequency.QuadPart)/Freq);//counter number
__asm
{
mov aL,0xB6
out 0x43,al
mov ax,Freq
out 0x42,al
mov al, ah
out 0x42,al
in al,0x61
or al,3
out 0x61,al
}
}void AsmNoSound(void)
{
__asm
{
in al,0x61
and aL, 0xfc
out 0x61, aL
}
}
很少这么用了?
好人做到底请问如何判断是nt还是9x?
http://ygyuan.3322.net/有动态链接库,可以在 Win9x 下发出不同频率的声音.有例程.
具体的看看msdn!
{
UINT frequency = freq; _outp(0x43, (char)0xb6); if (frequency > 0)
frequency = (unsigned) (1193180L/frequency); _outp(0x42, (char)frequency);
_outp(0x42, (char)(frequency >> 8)); for (UINT i=0;i<(100000*dura);i++)
_outp(0x61, (char)(_inp(0x61) | 0x3));
_outp(0x61, (char)(_inp(0x61) & ~0x3));
}
BOOL Beep(
DWORD dwFreq, // sound frequency
DWORD dwDuration // sound duration
);
/////////////////////////////////////////////////////////////////////////////////////////// // 函数名: Sound
// 编写者:
// 参考资料:
// 功 能:
// 输入参数: nFreq:嗽叭鸣叫频率 nTimeOut:嗽叭鸣叫持续时间
// 输出参数:
void Sound(const unsigned long& nFreq,const unsigned long& nTimeOut)
{
assert(nFreq > 0 && nTimeOut > 0); unsigned uStatus,uRatio,uLobyte,uHibyte;
uStatus=_inp(0x61);
_outp(0x43,0xb6);
uRatio = (unsigned)(1193180L/nFreq);//发声速率
uLobyte=uRatio&0xff;//速率低字节
_outp(0x42,uLobyte);
uHibyte=(uRatio>>8)&0xff;//速率高字节
_outp(0x42,uHibyte);
_outp(0x61,(uStatus|3));//开始发声
Sleep(nTimeOut);
_outp(0x61,(uStatus&~3));
}