我在使用內置函數PlaySound時遇到了一些問題。我連續地接收兩個錯誤,第一個是:在C++中正確使用PlaySound函數
類型 「爲const char *」 的說法是,類型爲 「LPCWSTR」 的參數不相容,
,第二個是:
'BOOL PlaySoundW(LPCWSTR,HMODULE,DWORD)':不能將參數1從'const char [35]'轉換爲'LPCWSTR'。
我似乎無法自己解決這些問題,並希望找出如何擺脫錯誤的一些幫助。以下是我的源代碼部分,包括我認爲會導致錯誤的部分。
#include <iostream>
#include <string>
#include <iomanip>
#include <dos.h>
#include <windows.h>
#include <playsoundapi.h>
#include <mmsystem.h>
using namespace std;
int main()
{
PlaySound("C:\\Users\\Cristian\\Desktop\\cafe.mp3", NULL, SND_FILENAME | SND_ASYNC);
return 0;
}
如果我錯誤地使用了PlaySound功能,請將我指向正確的方向。