我正在尝试在 C++ 中使用 Playsound()。
我已经查看了所有内容,但总是听到默认的 Windows 错误声音。
PlaySound(TEXT("D:\\Pokemon Game Stuff\\Programming\\Tests\\city simulator\\Sound.wav"), NULL, SND_FILENAME | SND_ASYNC);
winmm.lib 已在链接器设置中设置。 完整位置和文件名已经过测试。 我正在使用 Code::Blocks 并使用 C++ 14 标准进行编译。
最佳答案
根据 PlaySound()
文档:
SND_FILENAME
ThepszSound
parameter is a file name. If the file cannot be found, the function plays the default sound unless theSND_NODEFAULT
flag is set....
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. If the function cannot find the specified sound and theSND_NODEFAULT
flag is not specified,PlaySound
uses the default system event sound instead. If the function can find neither the system default entry nor the default sound, it makes no sound and returnsFALSE
.
仔细检查该文件是否确实存在于您指定的路径中,并且运行您的应用的用户是否有权访问该文件。
关于c++ - Playsound() 在 C++ 中播放 Windows 错误声音,我已经包含了 winmm.lib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50070188/