#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)
{
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;
}