怎样播放音乐
怎样实现在VC 6.0中播放音乐?要用到一些什么函数,怎么去组合它们啊?麻烦各位帮帮忙吧!
#include <stdio.h> #include <windows.h> typedef MCIERROR WINAPI (*MCISENDSTRING)(LPCTSTR, LPTSTR, UINT, HANDLE); int main(void) { HMODULE hLib; hLib = LoadLibrary("Winmm.dll"); if (hLib == 0) return 0; MCISENDSTRING mciSendString = (MCISENDSTRING)GetProcAddress(hLib, "mciSendStringA"); if (mciSendString != 0) { //if (mciSendString("open C:\\TEMP\\Test\\迷魂香(翁立友).wav alias MyPlay", NULL, 0, NULL) == 0) if (mciSendString("open C:\\TEMP\\Test\\抹去泪水(韩宝仪).mp3 alias MyPlay", NULL, 0, NULL) == 0) { mciSendString("play MyPlay", NULL, 0, NULL); //mciSendString("play MyPlay repeat", NULL, 0, NULL) //重复播放 printf("按任一键...暂停播放"); getchar(); mciSendString("pause MyPlay", NULL, 0, NULL); printf("按任一键...继续播放"); getchar(); mciSendString("resume MyPlay", NULL, 0, NULL); printf("按任一键...停止播放"); getchar(); mciSendString("stop MyPlay", NULL, 0, NULL); printf("按任一键...关闭播放"); getchar(); mciSendString("close MyPlay", NULL, 0, NULL); } } FreeLibrary(hLib); return 0; }