MCI_windows编程实现实例
b.
{ 录音示例 =
HWND hwnd;
MCI_OPEN_PARMS mciopen;
MCI_RECORD_PARMS mci1;
MCI_SAVE_PARMS mcisave;
DWORD rtrn;
char b[80];
hwndGetActiveWindow()->m_hWnd;
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;
mci1.dwCallback = (DWORD)hwnd; rtrn = mciSendCommand(wDeviceID,MCI_RECORD,MCI_NOTIFY,(DWORD)(LPVOID)&mci1); if (rtrn != 0L){ mciopen.lpstrElementName = "e:\\ding.wav"; mcisave.lpfilename = "e:\\ding.wav"; mciopen.lpstrDeviceType = "waveaudio";
mciGetErrorString(rtrn,(LPSTR)b,80);
::MessageBox(hwnd,b,"MCI Error",MB_OK);
mciSendCommand(wDeviceID,MCI_CLOSE,0,NULL);
}
}
//保存到文件并停止录音
{
HWND hwnd;
MCI_SAVE_PARMS mcisave;
MCI_OPEN_PARMS mciopen;
DWORD rtrn;
char b[80];
hwndGetActiveWindow()->m_hWnd;
mcisave.dwCallback = (DWORD)hwnd; mciopen.lpstrElementName = "e:\\ding.wav"; mcisave.lpfilename = "e:\\ding.wav"; mciopen.lpstrDeviceType = "waveaudio";