1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70:
| uses MMSystem;
mciSendstring('SET CDAUDIO DOOR OPEN WAIT', nil, 0, Self.Handle);
function OpenCD(Drive: Char): Boolean; var Res: MciError; OpenParm: TMCI_Open_Parms; Flags: DWORD; S: string; DeviceID: Word; begin Result := False; S := Drive + ':'; Flags := MCI_OPEN_TYPE or MCI_OPEN_ELEMENT; with OpenParm do begin dwCallback := 0; lpstrDeviceType := 'CDAudio'; lpstrElementName := PChar(S); end; Res := mciSendCommand(0, MCI_OPEN, Flags, Longint(@OpenParm)); if Res <> 0 then Exit; DeviceID := OpenParm.wDeviceID; try Res := mciSendCommand(DeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0); if Res = 0 then Exit; Result := True; finally mciSendCommand(DeviceID, MCI_CLOSE, Flags, Longint(@OpenParm)); end; end;
mciSendstring('SET CDAUDIO DOOR CLOSED WAIT', nil, 0, Self.Handle);
function CloseCD(Drive: Char): Boolean; var Res: MciError; OpenParm: TMCI_Open_Parms; Flags: DWORD; S: string; DeviceID: Word; begin Result := False; S := Drive + ':'; Flags := MCI_OPEN_TYPE or MCI_OPEN_ELEMENT; with OpenParm do begin dwCallback := 0; lpstrDeviceType := 'CDAudio'; lpstrElementName := PChar(S); end; Res := mciSendCommand(0, MCI_OPEN, Flags, Longint(@OpenParm)); if Res <> then Exit; DeviceID := OpenParm.wDeviceID; try Res := mciSendCommand(DeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, 0); if Res = 0 then Exit; Result := True; finally mciSendCommand(DeviceID, MCI_CLOSE, Flags, Longint(@OpenParm)); end; end; |