При наличии более одного CD-ROM в системе рекомендуется обратиться к следующим функциям:
Код | unit DriveTools;
interface
function CloseCDDrive(Drive: char): boolean; function OpenCDDrive(Drive: char): boolean;
implementation
uses Windows, SysUtils, MMSystem;
function OpenCDDrive(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 begin DeviceID:=OpenParm.wDeviceID; try Res:=mciSendCommand(DeviceID, mci_Set, MCI_SET_DOOR_OPEN, 0); Result:=Res <> 0 finally mciSendCommand(DeviceID, mci_Close, Flags, Longint(@OpenParm)) end end end;
function CloseCDDrive(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 begin DeviceID:=OpenParm.wDeviceID; try Res:=mciSendCommand(DeviceID, mci_Set, MCI_SET_DOOR_CLOSED, 0); Result:=Res <> 0 finally mciSendCommand(DeviceID, mci_Close, Flags, Longint(@OpenParm)) end end end;
end. |
|