|
发表于 2014-7-30 23:12:35
|
显示全部楼层
扔给你一份C语言源码,直接改成WIN32就行 真不会了 就push call
- // Music.cpp : Defines the entry point for the application.
- //
- #include "stdafx.h"
- #pragma commet(lib,"WINMM.LIB")
- int WINAPI mainproc (HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
- {
- switch(msg)
- {
- case WM_INITDIALOG:
- break;
- case WM_CLOSE:
- EndDialog(hwnd,NULL);
- break;
- case WM_COMMAND:
- switch(LOWORD(wParam))
- {
- case IDC_OPEN:
- OPENFILENAME ofn;
- char szFile[256];//MAX_PATH操作系统定义的最大路径的长度
-
- ZeroMemory(&ofn,sizeof(ofn));
- ofn.lStructSize = sizeof(ofn);//定义结构体的大小,判断是win95还是win2000系统
- ofn.lpstrFile = szFile;//
- ZeroMemory(szFile,sizeof(szFile)/sizeof(char));
- ofn.nMaxFile = sizeof(szFile);
- ofn.lpstrFilter ="mp3文件\0*.mp3\0所有文件\0*.*\0\0";//过滤器
- ofn.Flags = OFN_EXPLORER |OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
- GetOpenFileName(&ofn);
-
- SetDlgItemText(hwnd,IDC_EDIT1,szFile);
- break;
-
- case IDC_PLAY:
- TCHAR play1[256];
- TCHAR play2[256];
- TCHAR getpath[256];
- GetDlgItemText(hwnd,IDC_EDIT1,getpath,sizeof(getpath)); //得到编辑框上面的路径名
- GetShortPathName(getpath,play1,sizeof(play1)); //得到短路径 play1保存短路径
- wsprintf(play2,"play %s",play1); //在路径前面加上个play
- SetDlgItemText(hwnd,IDC_EDIT1,play1); //显示出来短路径
- mciSendString(play2,NULL,0,NULL); //播放
- break; //退出 下面的跟这个同理
- case IDC_PAUSE: //暂停
-
- TCHAR pause1[256];
- TCHAR pause2[256];
- TCHAR getpath1[256];
- GetDlgItemText(hwnd,IDC_EDIT1,getpath1,sizeof(getpath1)); //="play e:/1.mp3";
- GetShortPathName(getpath1,pause1,sizeof(pause1)); //短路径
- wsprintf(pause2,"pause %s",pause1);
- SetDlgItemText(hwnd,IDC_EDIT1,pause1);
- mciSendString(pause2,NULL,0,NULL);
- break;
- case IDC_RESUME: //恢复
-
- TCHAR resume1[256];
- TCHAR resume2[256];
- TCHAR getpath3[256];
- GetDlgItemText(hwnd,IDC_EDIT1,getpath3,sizeof(getpath3)); //="play e:/1.mp3";
- GetShortPathName(getpath3,resume1,sizeof(resume1)); //短路径
- wsprintf(resume2,"resume %s",resume1);
- SetDlgItemText(hwnd,IDC_EDIT1,resume1);
- mciSendString(resume2,NULL,0,NULL);
- break;
- case IDC_CLOSE: //停止
-
- TCHAR close1[256];
- TCHAR close2[256];
- TCHAR getpath2[256];
- GetDlgItemText(hwnd,IDC_EDIT1,getpath2,sizeof(getpath2)); //="play e:/1.mp3";
- GetShortPathName(getpath2,close1,sizeof(close1)); //短路径
- wsprintf(close2,"close %s",close1);
- SetDlgItemText(hwnd,IDC_EDIT1,close1);
- mciSendString(close2,NULL,0,NULL);
- break;
-
- }
-
-
- }
- return 0;
- }
- int APIENTRY WinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow)
- {
- DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),NULL,mainproc);
- return 0;
- }
复制代码 |
|