Board index » delphi » Finding a CD Rom Drive

Finding a CD Rom Drive

I have a need to find out which Drive on a computer is the CD-Rom drive in
my Delphi 3 application.  Is there a way to do this?  If so, could someone
please provide me with some code, or point me in the right direction.

Thanks,
-= Jesse =-
http://www.msdlg.com
http://www.DaVinci-MIMS.com
ICQ # 36647056

 

Re:Finding a CD Rom Drive


Use the GetDriveType API to go through the drives from a to z.
And remember there can be more than one cd-rom drive present.

Jesse Castleberry <Je...@msdlg.com> skrev i en
nyhedsmeddelelse:j2Vz3.3669$R84.138...@typ12.nn.bcandid.com...

Quote
> I have a need to find out which Drive on a computer is the CD-Rom drive in
> my Delphi 3 application.  Is there a way to do this?  If so, could someone
> please provide me with some code, or point me in the right direction.

Re:Finding a CD Rom Drive


The following will list the drive types in a memo.  Modify as required for
you use.

procedure TForm1.Button1Click(Sender: TObject);
var
  Drive: Char;
  DriveLetter: String[4];
begin
  for Drive := 'A' to 'Z' do
  begin
    DriveLetter := Drive + ':\';
    case GetDriveType(PChar(Drive + ':\')) of
      DRIVE_REMOVABLE:
        Memo1.Lines.Add(DriveLetter + '     Floppy Drive');
      DRIVE_FIXED:
        Memo1.Lines.Add(DriveLetter + '     Fixed Drive');
      DRIVE_REMOTE:
        Memo1.Lines.Add(DriveLetter + '     Network Drive');
      DRIVE_CDROM:
        Memo1.Lines.Add(DriveLetter + '     CD-ROM Drive');
    end;
  end;
end;

Hope this helps!
--

Rodney E Geraghty
GERA-Tech
Ottawa, Canada
gera...@ibm.net

Jesse Castleberry <Je...@msdlg.com> wrote in article
<j2Vz3.3669$R84.138...@typ12.nn.bcandid.com>...

Quote
> I have a need to find out which Drive on a computer is the CD-Rom drive
in
> my Delphi 3 application.  Is there a way to do this?  If so, could
someone
> please provide me with some code, or point me in the right direction.

> Thanks,
> -= Jesse =-
> http://www.msdlg.com
> http://www.DaVinci-MIMS.com
> ICQ # 36647056

Re:Finding a CD Rom Drive


Quote
>I have a need to find out which Drive on a computer is the CD-Rom drive in
>my Delphi 3 application.  Is there a way to do this?  If so, could someone
>please provide me with some code, or point me in the right direction.

procedure GetCDDrives(Drvs: TStringList);
var
  i : char;
  drvpath : string;
begin
  Drvs.Clear;
  for i := 'A' to 'Z' do begin
    drvpath := i + ':\';
     if GetDriveType(PChar(drvpath)) = DRIVE_CDROM then
      Drvs.Add(drvpath);
  end;
end;

Chris

Other Threads