简体   繁体   English

在 MinGW c++ 中播放声音 (.wav) 文件而不打开应用程序

[英]Playing sound (.wav) file in MinGW c++ without opening an application

I am working on a console application (C++, MinGW, Windows 7) that I want to play a media file without invoking a software.我正在开发一个控制台应用程序(C++、MinGW、Windows 7),我想在不调用软件的情况下播放媒体文件。

Here's what I am looking for... at the end of a batch file or a C++ program that takes many minutes to complete, I'd like to "beep" by playing the file "C:\Windows\Media\tada.wav".这就是我要找的...在批处理文件或需要几分钟才能完成的 C++ 程序的末尾,我想通过播放文件“C:\Windows\Media\tada.wav”来“发出哔哔声” ”。

I would like to use something like one of these system commands, but don't want Windows to open whatever.WAV application.我想使用类似这些系统命令之一的东西,但不希望 Windows 打开whatever.WAV 应用程序。 It's one more window to close.还要关闭一个 window。

start "" "C:\Windows\Media\tada.wav"
"C:\Windows\Media\tada.wav"

Just like with any other Windows notification (new mail or Windows error), I'd like my computer to just play the file without opening any application.就像任何其他 Windows 通知(新邮件或 Windows 错误)一样,我希望我的计算机只播放文件而不打开任何应用程序。

How could I achieve this?我怎么能做到这一点?

You can have your C++ code call the Win32 API PlaySound() function when needed.您可以让您的 C++ 代码在需要时调用 Win32 API PlaySound() function。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM