VC++ Beep函数发不出音怎么办?
工程名称是Win32 console application;
#include <windows.h>
void main()
{
DWORD f=0x1b8;
DWORD t=1000;
Beep(f,t);
}
编译通过,运行不报错但无声音,求解。
[解决办法]
加个循环吧,不然只出声一次:
- C/C++ code
#include <windows.h>void main(){ DWORD f=0x1b8; DWORD t=1000; while (1) { Beep(f,t); } }
[解决办法]
Beep() 函数本来是用于让 PC Speaker 发声的,在 XP 和 2000 下只要有 PC Speaker 都能很好地工作。
但是在 Win7 里它却让声卡发声,而且效果比 PC Speaker 烂(尤其是连续播放短促音的时候)。
如果 LZ 在 Win7 下,需要开启音箱才能听到声音。
PS: 要引用贴子内容请点贴子右下角的"引用"
[解决办法]
你用的笔记本吧 笔记本一般是没有这个喇叭的
一般播放声音的喇叭和你指的这个喇叭不是同一个
Beep调用的喇叭只能发出几种固定音调的声音,一般用来发出台式机开机自检的信号音
播放音乐的喇叭是播放波形声音的,播放的是声卡的声音,可以播放很多种音调叠加成的声音
[解决办法]
我的机器没有问题
[解决办法]
笔记本应该不行的吧 至少我的不行 开机的时候没有台式机那种的滴的一声
[解决办法]
Speaker在主板上;不在声卡输出连接的喇叭上。
Beep Function
Generates simple tones on the speaker. The function is synchronous; it performs an alertable wait and does not return control to its caller until the sound finishes.
BOOL WINAPI Beep(
__in DWORD dwFreq,
__in DWORD dwDuration
);
Parameters
dwFreq
The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).
Windows Me/98/95: The Beep function ignores this parameter.
dwDuration
The duration of the sound, in milliseconds.
Windows Me/98/95: The Beep function ignores this parameter.
Return Value
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.
Remarks
Muting and volume control have no effect on Beep; you will still hear the tone. To silence the tone, use the following commands:
net stop beep
sc config beep start= disabled
Terminal Services: The beep is redirected to the client.
Windows Me/98/95: 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.
Example Code [C++]
The following example demonstrates the use of this function.
Beep( 750, 300 );
Requirements
Client
Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.
Server
Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header
Declared in Winbase.h; include Windows.h.
Library
Use Kernel32.lib.
DLL
Requires Kernel32.dll.
See Also
Error Handling Functions
MessageBeep
Notifying the User
Send comments about this topic to Microsoft
Build date: 8/10/2007