しかし、MCI_PLAYを実行すると固まってしまいます。
どうすればmp3を正常に再生できるか教えてください。
環境はWin7 Pro + VC++2008 ExpressEditionです。
#include<windows.h> #include<mmsystem.h> #include"resource.h" #pragma comment(lib,"winmm.lib") LRESULT CALLBACK WndProc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp); int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, int showCmd){ return DialogBox(hInst,MAKEINTRESOURCE(IDD_DIALOG1),NULL,(DLGPROC)WndProc); } LRESULT CALLBACK WndProc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp){ static char path[MAX_PATH]=""; static BOOL bPlaying=FALSE; static MCI_OPEN_PARMS mop; switch(msg){ case WM_DROPFILES: if(bPlaying==TRUE){ mciSendCommand(mop.wDeviceID,MCI_CLOSE,0,0); bPlaying=FALSE; } DragQueryFile((HDROP)wp,0,path,MAX_PATH); mop.lpstrDeviceType="MPEGVideo"; mop.lpstrElementName=path; MessageBox(hWnd,path,"",MB_OK); if(mciSendCommand(NULL,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,(DWORD)&mop)){ MessageBox(hWnd,"エラー","error",MB_OK); exit(-1); } MessageBox(hWnd,"a","",MB_OK); mciSendCommand(mop.wDeviceID,MCI_SEEK,MCI_SEEK_TO_START,0); MessageBox(hWnd,"b","",MB_OK); mciSendCommand(mop.wDeviceID,MCI_PLAY,0,0); bPlaying=TRUE; break; case WM_COMMAND: switch(LOWORD(wp)){ case IDCANCEL: if(bPlaying) mciSendCommand(mop.wDeviceID,MCI_CLOSE,0,0); EndDialog(hWnd,0); break; default: return FALSE; } break; default: return FALSE; } return TRUE; }