PlaySound用C哔哔声,但无法播放wav文件 [英] PlaySound in C beeps but does not play wav file
问题描述
在C,我的 PlaySound
不抛出任何错误的...而是打我想要的文件,它只是发出蜂鸣声。
In C, my PlaySound
is not throwing any errors... but instead of playing the file I want, it just beeps.
有什么建议?
我试过:
PlaySound("song1.wav", NULL, SND_ALIAS | SND_APPLICATION);
和
PlaySound("song1.wav", NULL, SND_FILENAME);
但我得到了同样的结果。
But I got the same result.
推荐答案
引自PlaySound API说明,在msdn.microsoft.com:
Quote from PlaySound API description, at msdn.microsoft.com:
PlaySound
搜索声音文件以下目录:该
当前目录; Windows目录; Windows系统
目录;在 PATH
环境变量中列出目录;和
在网络中映射的目录列表。
PlaySound
searches the following directories for sound files: the current directory; the Windows directory; the Windows system directory; directories listed in thePATH
environment variable; and the list of directories mapped in a network.
如果该功能无法找到指定的声音和
SND_NODEFAULT
没有指定标志, PlaySound
使用默认
系统声音事件,而不是(你的情况BEEP)。
If the function cannot find the specified sound and the
SND_NODEFAULT
flag is not specified, PlaySound
uses the default
system event sound instead(In your case the BEEP).
如果该函数可以发现,无论是系统默认的项目,也不是
默认的声音,它使没有声音并返回 FALSE
。
If the function can find neither the system default entry nor the
default sound, it makes no sound and returns FALSE
.
所以,添加文件目录路径到 PATH
环境变量的窗口。这应该解决您的问题。
So, add the file directory path into the PATH
environment variable in windows. That should fix your issue.
这篇关于PlaySound用C哔哔声,但无法播放wav文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!