private int MciSet(int itemType, int item, int dwflags) { int err = -1; StringBuilder buf = new StringBuilder(1000); MCI_SET_PARMS mciSP = new MCI_SET_PARMS(); if (deviceID > 0) { if (itemType == 0) { mciSP.dwTimeFormat = item; err = mciSendCommandA(deviceID, MCI_SET, dwflags, ref mciSP); } else if (itemType == 1) { mciSP.dwAudio = item; err = mciSendCommandA(deviceID, MCI_SET, dwflags, ref mciSP); } else { mciSP.dwSpeed = item; err = mciSendCommandA(deviceID, MCI_SET, dwflags, ref mciSP); } } return err; }
/// <summary> /// 关闭 CD-ROM。 /// </summary> public void CloseCdRom() { if (deviceID > 0 && (devCaps & DevCaps.CanEject) == DevCaps.CanEject) { int err = -1; StringBuilder buf = new StringBuilder(1000); MCI_SET_PARMS mciSP = new MCI_SET_PARMS(); err = mciSendCommandA(deviceID, MCI_SET, MCI_WAIT | MCI_SET_DOOR_CLOSED, ref mciSP); if (err != 0) { mciGetErrorStringA(err, buf, 1000); //throw new ApplicationException("关闭 CD-ROM 出错," + buf.ToString()); } } }
private static extern int mciSendCommandA( Int32 wDeviceID, UInt32 uMessage, Int32 dwParam, ref MCI_SET_PARMS Any);