使用文件名打开复合设备
以下示例通过指定名为“TIMPANI”的波形音频文件打开波形音频设备。WAV“,使用 mciSendCommand 函数。
UINT wDeviceID;
DWORD dwReturn;
MCI_OPEN_PARMS mciOpenParms;
// Opens a waveform-audio device by specifying the device and
// file name.
mciOpenParms.lpstrDeviceType = "waveaudio";
mciOpenParms.lpstrElementName = "timpani.wav";
if (dwReturn = mciSendCommand(NULL, MCI_OPEN,
MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)(LPVOID) &mciOpenParms))
{
// Error, unable to open device.
}
// The device opened successfully; get the device ID.
wDeviceID = mciOpenParms.wDeviceID;