Hi
BEAT_Heart,
感谢在MSDN论坛发帖。
根据MSDN官方文档,PlaySound()采用LPCTSTR(const TCHAR *)作为输入。在WinDef.h中,TCHAR映射到wchar_t或char取决于是否定义了UNICODE。
#ifdef UNICODE
typedef LPCWSTR LPCTSTR;
#else
typedef LPCSTR LPCTSTR;
#endif
所以建议你尝试以下几种方式。
PlaySoundW(TEXT("E:\\K.wav"), NULL, SND_FILENAME|SND_ASYNC);
PlaySoundW(L"E:\\K.wav", NULL, SND_FILENAME|SND_ASYNC);
在我的Win10, vs2017上测试可以正常播放。
希望对你有所帮助。
Best Regards,
Sera Yu
MSDN Community Support<br/> Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this
thread. If you have any compliments or complaints to MSDN Support, feel free to contact <a href="mailto:MSDNFSF@microsoft.com">MSDNFSF@microsoft.com</a>.