我要是用它来播放x64dbg.exe 内置的资源中的.wav文件 ,那个路径是不是得修改一下?
因为,我看到的QT的源码中是这样的:
[C] 纯文本查看 复制代码 QFile file(":/icons/images/egg.wav"); <=======看这句!!!!
if(file.open(QIODevice::ReadOnly))
{
QByteArray egg = file.readAll();
PlaySoundA(egg.data(), 0, SND_MEMORY | SND_ASYNC | SND_NODEFAULT);
}
[C++] 纯文本查看 复制代码 #include <Windows.h>
#include <mmsystem.h>
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <assert.h>
#pragma comment(lib,"WinMM.Lib")
using namespace std;
BOOL MByteToWChar(LPCSTR lpcszStr, LPWSTR lpwszStr, DWORD dwSize)
{
// Get the required size of the buffer that receives the Unicode
// string.
DWORD dwMinSize;
dwMinSize = MultiByteToWideChar(CP_ACP, 0, lpcszStr, -1, NULL, 0);
assert(dwSize >= dwMinSize);
// Convert headers from ASCII to Unicode.
MultiByteToWideChar(CP_ACP, 0, lpcszStr, -1, lpwszStr, dwMinSize);
return TRUE;
}
int main(int argc, char** argv)
{
string s = "D:\\MyDesktop\\6.wav";// "bt.wav";
wchar_t wText[30] = { 0 };
MByteToWChar(s.c_str(), wText, sizeof(wText) / sizeof(wText[0]));
PlaySound(wText, NULL, SND_FILENAME | SND_SYNC);
system("pause");
return 0;
}
|