// 原文:
// 对比原文有点小改动
// 设备使用 MPEGVideo = mciqtz32.dll, 可能要在注册表里加上一些东西
#include
#include
#pragma comment(lib,"winmm.lib")
BOOL PlayFile(char * szFilePath)
{
UINT DeviceID;
MCI_OPEN_PARMS mciOpen;
MCI_PLAY_PARMS mciPlay;
MCIERROR mciError;
MCI_GENERIC_PARMS mciGeneric;
mciOpen.lpstrDeviceType = "mpegvideo";
mciOpen.lpstrElementName = szFilePath;
mciError = mciSendCommand(0,MCI_OPEN,
MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,(DWORD)&mciOpen);
if (mciError!=0)
return FALSE;
DeviceID = mciOpen.wDeviceID;
//mciError=mciSendCommand(DeviceID,MCI_WINDOW,0,(DWORD)&mciGeneric);
//if (mciError!=0)
// return FALSE;
mciError = mciSendCommand(DeviceID,MCI_PLAY,0 ,(DWORD)&mciPlay);
if (mciError!=0)
return FALSE;
return TRUE;
}
int main(int argc, char* argv[])
{
BOOL bIsPlaying=PlayFile("e:\\1.mp3");
while (bIsPlaying)
{
Sleep(1000);
}
return 0;
}
阅读(955) | 评论(0) | 转发(0) |