#pragma comment( lib, "Winmm.lib" ) 不工作

#pragma comment( lib, "Winmm.lib" ) Not working

我正在尝试使用 PlaySound,我将

#include <windows.h>
#include <mmsystem.h>
#pragma comment( lib, "Winmm.lib" )
using namespace std;

int main()
{

PlaySound(L"C:\Users\iD Student\Downloads\HarryPotter.mp3", 0, SND_FILENAME);

}

它没有播放我想要的声音,而是播放了一些默认的 Windows 声音。

PlaySound 不支持 .mp3 文件。它只支持 .wav 文件。

这是播放声音的简单代码:

#include <windows.h>
#include <mmsystem.h>
#pragma comment( lib, "Winmm.lib" )
using namespace std;

int main()
{
//Replace C:\Users\iD Student\Downloads\HarryPotter.wav with the location of your file
PlaySound(L"C:\Users\iD Student\Downloads\HarryPotter.wav", 0, SND_FILENAME);

}