使用mciSendCommand播放一段midi音频,在x86下可以正常播放,但是在x64下没有声音。
#include<Windows.h>
#pragma comment(lib, "winmm.lib")
int main()
{
UINT wDeviceID;
DWORD dwReturn;
MCI_OPEN_PARMS mciOpenParms;
MCI_PLAY_PARMS mciPlayParms;
//打开设备
mciOpenParms.lpstrDeviceType = TEXT("sequencer");
mciOpenParms.lpstrElementName = TEXT("bgm.mid");
if (dwReturn = mciSendCommand(NULL, MCI_OPEN,
MCI_OPEN_ELEMENT | MCI_WAIT ,
(DWORD_PTR)(static_cast<LPVOID>(&mciOpenParms))))
{
return (dwReturn);
}
wDeviceID = mciOpenParms.wDeviceID;
//播放音乐
if (dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_WAIT,
(DWORD_PTR)(static_cast<LPVOID>(&mciPlayParms))))
{
mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
return (dwReturn);
}
system("pause");
return 0;
}