How to open a specific drive when you have two CD-ROM drives (Views: 704)
Problem/Question/Abstract: How to open a specific drive when you have two CD-ROM drives Answer: function IsDriveCD(Drive: Char): boolean; var DrivePath: string; begin DrivePath := Drive + ':\'; Result := (GetDriveType(PChar(DrivePath)) = DRIVE_CDROM); end; function EjectCD(Drive: Char): boolean; var mp: TMediaPlayer; begin Result := false; if not IsDriveCD(Drive) then exit; mp := TMediaPlayer.Create(nil); try mp.Visible := false; mp.Parent := Application.Mainform; mp.Shareable := true; mp.DeviceType := dtCDAudio; mp.FileName := Drive + ':'; mp.Open; mp.Eject; mp.Close; finally mp.Free; end; end; |