MCI_windows编程实现实例(2)
发布时间:2021-06-06
发布时间:2021-06-06
MCI_windows编程实现实例
五、使用示例
1. sndPlaySound("ding.wav",SND_SYNC);
2. PlaySound("chord.wav",NULL,SND_SYNC );
3. 使用两个高级MCI函数
a. 播放MIDI文件示例
{
HWND hwnd;
MCI_OPEN_PARMS mciopen;
MCI_OPEN_PARMS mciplay;
DWORD rtrn;
char b[80];
hwndGetActiveWindow()->m_hWnd;
= mciopen.lpstrElementName = "e:\\test\\test.rmi";
rtrn = mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE|MCI_OPEN_ELEMENT, (DWORD)(LPVOID)&mciopen); if(rtrn != 0){
mciGetErrorString(rtrn,(LPSTR)b,80);
::MessageBox(hwnd,b,"MCI ERROR!",MB_OK);
}
wDeviceID = mciopen.wDeviceID; mciplay.dwCallback = (DWORD)hwnd; rtrn = mciSendCommand(wDeviceID,MCI_PLAY,MCI_NOTIFY,(DWORD)(LPVOID)&mciplay); if (rtrn != 0L){ mciopen.lpstrDeviceType = "sequencer" ; =
mciGetErrorString(rtrn,(LPSTR)b,80);
::MessageBox(hwnd,b,"MCI Error",MB_OK);
mciSendCommand(wDeviceID,MCI_CLOSE,0,NULL);
}
}
//停止播放
{
HWND hwnd;
MCI_GENERIC_PARMS mcistop;
hwndGetActiveWindow()->m_hWnd;
} mcistop.dwCallback = (DWORD)hwnd; mciSendCommand(MCI_DEVTYPE_SEQUENCER,MCI_STOP,0,(DWORD)(LPVOID)&mcistop);
上一篇:2016年电网调度运行工作计划
下一篇:大气压强趣味实验案例分析