N
nzfboy
Unregistered / Unconfirmed
GUEST, unregistred user!
控制多个关驱中一个
例如使用MCI命令控制多个光驱的弹出关闭:(Visual C++)
// 例子:弹出光驱F CDRomOpen(TRUE,'F')
// 关闭光驱F CDRomOpen(FALSE,'F')
void CDRomOpen(BOOL bOpenDrive,TCHAR cDrive)
{
MCI_OPEN_PARMS open;
MCI_STATUS_PARMS status;
DWORD flags;
TCHAR szDriveName[4];
strcpy(szDriveName,"?:");
::ZeroMemory(&open,sizeof(MCI_OPEN_PARMS));
open.lpstrDeviceType=(LPCSTR)MCI_DEVTYPE_CD_AUDIO;
szDriveName[0]=cDrive;
open.lpstrElementName=szDriveName;
flags=MCI_OPEN_TYPE¦MCI_OPEN_TYPE_ID¦MCI_OPEN_ELEMENT¦MCI_OPEN_SHAREABLE;
if(!mciSendCommand(0,MCI_OPEN,flags,(unsigned long)&open)){
status.dwItem=MCI_STATUS_READY;
if(bOpenDrive)
mciSendCommand(open.wDeviceID,MCI_SET,MCI_SET_DOOR_OPEN,0);
else
mciSendCommand(open.wDeviceID,MCI_SET,MCI_SET_DOOR_CLOSED,0);
mciSendCommand(open.wDeviceID,MCI_CLOSE,MCI_WAIT,0);
}
}
例如使用MCI命令控制多个光驱的弹出关闭:(Visual C++)
// 例子:弹出光驱F CDRomOpen(TRUE,'F')
// 关闭光驱F CDRomOpen(FALSE,'F')
void CDRomOpen(BOOL bOpenDrive,TCHAR cDrive)
{
MCI_OPEN_PARMS open;
MCI_STATUS_PARMS status;
DWORD flags;
TCHAR szDriveName[4];
strcpy(szDriveName,"?:");
::ZeroMemory(&open,sizeof(MCI_OPEN_PARMS));
open.lpstrDeviceType=(LPCSTR)MCI_DEVTYPE_CD_AUDIO;
szDriveName[0]=cDrive;
open.lpstrElementName=szDriveName;
flags=MCI_OPEN_TYPE¦MCI_OPEN_TYPE_ID¦MCI_OPEN_ELEMENT¦MCI_OPEN_SHAREABLE;
if(!mciSendCommand(0,MCI_OPEN,flags,(unsigned long)&open)){
status.dwItem=MCI_STATUS_READY;
if(bOpenDrive)
mciSendCommand(open.wDeviceID,MCI_SET,MCI_SET_DOOR_OPEN,0);
else
mciSendCommand(open.wDeviceID,MCI_SET,MCI_SET_DOOR_CLOSED,0);
mciSendCommand(open.wDeviceID,MCI_CLOSE,MCI_WAIT,0);
}
}