PlaySound用C哔哔声,但无法播放wav文件

编程入门 行业动态 更新时间:2024-10-23 13:25:04
本文介绍了PlaySound用C哔哔声,但无法播放wav文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在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:

Quote from PlaySound API description, at msdn.microsoft:

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 the PATH 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文件

本文发布于:2023-07-11 12:15:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1094023.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法播放   文件   PlaySound   哔哔声   wav

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!