How to implement switch CD-ROM

xiaoxiao2021-03-06  108

How to implement switch CD-ROM

For the operation of the CD-ROM, it can be implemented by the MCISendCommand function.

Below is the code implemented with VC:

// Device ID

DWORD WDEVID;

// Open device parameters

MCI_open_parms mciom

// Set the device name to CD_ROM

MCIM.LPSTRDEVICEPE = "cdaudio";

// Open this device

IF (McISendCommand (0, MCI_open, MCI_Open_Type, (DWORD) & MCIM))

{

Return;

}

// Get the device ID

Wdevid = mciom.wdeviceID;

/ / Open CD-ROM

MCI_set_parms mc.com;

IF (McISendCommand (WDEVID, MCI_SET, MCI_SET_DOOR_OPEN | MCI_SET_OFF, (DWORD) (LPSTR) & mciset)

{

}

// Turn off CD-ROM

IF (McISendCommand (WDEVID, MCI_SET, MCI_SET_DOOR_CLOSED | MCI_SET_OFF, (DWORD) (LPSTR) & MCSET)

{

}

// Turn off the device

McISendCommand (WDEVID, MCI_Close, 0, 0);

转载请注明原文地址:https://www.9cbs.com/read-96357.html

New Post(0)