事例代码如下
#include<windows.h>
#include<stdio.h>
#pragma comment(lib,"WinMM.Lib")
void main()
{
PlaySound("c:\\dui12.wav",NULL,SND_FILENAME|SND_ASYNC)
}
2:功能和Playsound函数一样差劲的函数undplaysound
#include<windows.h>
#include<stdio.h>
#pragma comment(lib,"WinMM.Lib")
void main()
{
undPlaySound("c:\\dui12.wav",NULL,SND_FILENAME|SND_ASYNC)
}
3:功能强大的函数,支持混音的MCI类
事例代码如下
#include<windows.h>
#include "mmsystem.h"//导入声音头文件
#pragma comment(lib,"winmm.lib")//导入声音头文件库
#include<stdio.h>
void PlayMp3()
void main()
{
PlayMp3()
PlaySound("C:\\Normal2.wav", NULL, SND_FILENAME | SND_ASYNC | SND_LOOP)
system("pause")
}
void PlayMp3()
{
char buf[128]
char str[128] = {0 }
int i = 0
//use mciSendCommand
MCI_OPEN_PARMS mciOpen
MCIERROR mciError
//SetWindowText(NULL,"12345")
mciOpen.lpstrDeviceType = "mpegvideo"
mciOpen.lpstrElementName = "c:\\WELCOME.WAV"
mciError = mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,(DWORD)&mciOpen)
if(mciError)
{
mciGetErrorString(mciError,buf,128)
printf("send MCI_OPEN command failed:%s\n",buf)
return
}
UINT DeviceID = mciOpen.wDeviceID
MCI_PLAY_PARMS mciPlay
mciError = mciSendCommand(DeviceID,MCI_PLAY,0 ,(DWORD)&mciPlay)
if(mciError)
{
printf("send MCI_PLAY command failed\n")
return
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)