c语言 写的播放音乐

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*.mp3\0");


ofn.nFilterIndex = 2;


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[MAX_PATH];


MessageBox(NULL,szFile,"",MB_OK);
GetShortPathName(szFile, shortPath, sizeof(shortPath));
TCHAR cmd[MAX_PATH+10];
MessageBox(hwnd, shortPath, TEXT("TestFileName"), MB_OK);
wsprintf(cmd, "play %s", shortPath);
mciSendString(cmd, "", 0, NULL);


}

你可能感兴趣的:(c,cmd,null,音乐,语言,Path)