MCI_OVLY_OPEN_PARMS Structure 结构中的成员 lpstrDeviceType的值

来源:互联网 发布:office2016激活 知乎 编辑:程序博客网 时间:2024/06/05 17:53
MCI 播放设备对应的文件类型在注册表中的位置 
lpstrDeviceType

Name or constant identifier of the device type. (The name of the device is typically obtained from the registry or SYSTEM.INI file.) If this member is a constant, it can be one of the values listed in MCI Device Types.

          MCI Device Types

MSDN

Name or constant identifier of the device type. (The name of the device is typically obtained from the registry or SYSTEM.INI file.) If this member is a constant, it can be one of the values listed in

The following values identify devices in MCI messages and structures:

ValueMeaningMCI_ALL_DEVICE_IDAny deviceMCI_DEVTYPE_ANIMATIONAnimation-playback deviceMCI_DEVTYPE_CD_AUDIOCD audio deviceMCI_DEVTYPE_DATDigital-audio tape deviceMCI_DEVTYPE_DIGITAL_VIDEODigital-video playback deviceMCI_DEVTYPE_OTHERUndefined deviceMCI_DEVTYPE_OVERLAYVideo-overlay deviceMCI_DEVTYPE_SCANNERScanner deviceMCI_DEVTYPE_SEQUENCERMIDI sequencer deviceMCI_DEVTYPE_VCRVideo-cassette recorderMCI_DEVTYPE_VIDEODISCVideodisc playerMCI_DEVTYPE_WAVEFORM_AUDIO

Waveform-audio device

实在看不懂,好像9X时代的东东.最后终于在注册表中找到了.

HKEY_LOCAL_MACHINE/Software/Microsoft/Windows NT/CurrentVersion/MCI Extensions中有所有的文件类型,和相对应的播放设备。
MCI播放mp3的例子:

#include<windows.h>
#include<stdio.h>
#include<mmsystem.h>

#pragma comment(lib,"winmm.lib")

void main()
{
char buf[128];
//use mciSendString()
//mciSendString("play e://songs//把根留住.mp3",buf,sizeof(buf),NULL);
//mciSendString("play e://songs//zhj.mp3",buf,sizeof(buf),NULL);
char str[128] = {0 };
int i = 0;

//use mciSendCommand
MCI_OPEN_PARMS mciOpen;
MCIERROR mciError;
SetWindowText(NULL,"12345");
//mciOpen.lpstrDeviceType = (LPCTSTR)MCI_ALL_DEVICE_ID;
//mciOpen.lpstrDeviceType = "waveaudio"; //只能播放.wav文件
//mciOpen.lpstrDeviceType = "avivideo"; //*.avi
mciOpen.lpstrDeviceType = "mpegvideo";
//mciOpen.lpstrDeviceType = "sequencer";
mciOpen.lpstrElementName = "e://songs//zhj.mp3";
//mciOpen.lpstrElementName = "e://movie//first.avi";
//mciOpen.lpstrElementName = "c://winnt//media//Windows 登录音.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;
}

/*
while(1)
{
sprintf(str,"now playing/t%d/tseconds",i);
printf("%s/r",str);
i++;
Sleep(1000);
}
*/
}