mciSendString 不出声音 如其mciSendString("play c:/1.mp3")就有声音 换成数组表示路径就没有
mciSendString 不出声音 如果mciSendString("play c:/1.mp3"....)就有声音 换成数组表示路径就没有
case IDC_OK:
{
OPENFILENAME ofn;
char szFile[MAX_PATH];
ZeroMemory(&ofn,sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = TEXT('\0');
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = TEXT("ALL\0*.*\0Text\0*.TXT\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.hwndOwner = hwnd;
ofn.Flags = OFN_EXPLORER |OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn))
{
TCHAR shortPath[50];
TCHAR p[70];
// mciSendString("stop mymusic",NULL,0,NULL);
GetShortPathName(szFile,shortPath,sizeof(shortPath));
wsprintf(p,"paly %s",shortPath);
mciSendString(p,NULL,0,NULL);
SetDlgItemText(hwnd,IDC_EDIT1,szFile);
}
}
------解决方案--------------------
case IDC_OK:
{
OPENFILENAME ofn;
char szFile[MAX_PATH];
ZeroMemory(&ofn,sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = TEXT('\0');
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = TEXT("ALL\0*.*\0Text\0*.TXT\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.hwndOwner = hwnd;
ofn.Flags = OFN_EXPLORER |OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn))
{
TCHAR shortPath[50];
TCHAR p[70];
// mciSendString("stop mymusic",NULL,0,NULL);
GetShortPathName(szFile,shortPath,sizeof(shortPath));
wsprintf(p,"paly %s",shortPath);
mciSendString(p,NULL,0,NULL);
SetDlgItemText(hwnd,IDC_EDIT1,szFile);
}
}
C
API
mciSendString
------解决方案--------------------
case IDC_OK:
{
OPENFILENAME ofn;
TCHAR szFile[MAX_PATH];
ZeroMemory(&ofn,sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = _T("ALL\0*.*\0Text\0*.TXT\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.hwndOwner = hwnd;
ofn.Flags = OFN_EXPLORER
------解决方案--------------------
OFN_PATHMUSTEXIST
------解决方案--------------------
OFN_FILEMUSTEXIST;
if (GetOpenFileName(&ofn))
{
TCHAR shortPath[50];
TCHAR p[70];
GetShortPathName(szFile,shortPath,sizeof(shortPath));
_stprintf(p,_T("paly %s"),shortPath);
mciSendString(p,NULL,0,NULL);
SetDlgItemText(hwnd,IDC_EDIT1,szFile);
}
}