Board index » delphi » Finding/detecting CD-rom drive

Finding/detecting CD-rom drive

Hi,
I'm making a little program, and needs the program to find/detect the
drive letter of the cd-rom drive! How's that dine??? I'm usinfg Delphi
3.

Jan

 

Re:Finding/detecting CD-rom drive


Quote
>I'm making a little program, and needs the program to find/detect the
>drive letter of the cd-rom drive! How's that dine??? I'm usinfg Delphi
>3.

>Jan

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

Re:Finding/detecting CD-rom drive


Hi Jan & Rikke!

Use GetLogicalDrives.

Rudy
============================
Jan Hecker & Rikke Skaanes schreef:

Quote

> Hi,
> I'm making a little program, and needs the program to find/detect the
> drive letter of the cd-rom drive! How's that dine??? I'm usinfg Delphi
> 3.

> Jan

Re:Finding/detecting CD-rom drive


  Easy enough:  This will find the first CD-ROM in the format 'x:\'  (where
x is the *FIRST* CD-ROM)...  --  use it:  MyVar := FindCDROM;

function FindCDROM: shortstring;
var
  AList                         : TStringList;
  Counter                       : integer;
begin
  Result := 'no CDROM present';
  AList := TStringList.Create;
  ListDrives(AList);
  for Counter := 0 to AList.Count-1 do
    if GetDriveType(PChar(Alist.Strings[Counter])) = DRIVE_CDROM then
      Result := Alist.Strings[Counter]
end;

procedure ListDrives(Strings: TStringList);
const BufSize = 256;
var
  Buffer, P: PChar;
begin
  GetMem(Buffer, BufSize);
  try
    Strings.BeginUpdate;
    try
      Strings.Clear;
      if GetLogicalDriveStrings(BufSize, Buffer) <> 0 then begin
        P := Buffer;
        while P^ <> #0 do begin
          Strings.Add(P);
          Inc(P, StrLen(P) + 1);
        end;
      end;
    finally
      Strings.EndUpdate;
    end;
  finally
    FreeMem(Buffer, BufSize);
  end;
end;

--
Jason Wallace
SL Software
Dark...@SLSoftware.reno.nv.us
--
"We are Microsoft.  Resistance is Futile.  You will be assimilated.
--

Jan Hecker & Rikke Skaanes <rikke...@get2net.dk> wrote in message
news:3722E2CD.5347E78@get2net.dk...

Quote
> Hi,
> I'm making a little program, and needs the program to find/detect the
> drive letter of the cd-rom drive! How's that dine??? I'm usinfg Delphi
> 3.

> Jan

Re:Finding/detecting CD-rom drive


Jan,
  I have an example on my webpage that does exactly that.

--
Good Luck!!
    -Dave
Inprise Certified Delphi 4 Client/Server developer
http://www.erols.com/dparsons

Quote
Bruno BORNIL <bruno.bor...@overlap.fr> wrote in message

news:37273EA8.BB402B13@overlap.fr...

Jan Hecker & Rikke Skaanes a crit :

Quote
> Hi,
> I'm making a little program, and needs the program to find/detect the
> drive letter of the cd-rom drive! How's that dine??? I'm usinfg Delphi
> 3.

> Jan

Hello,

   You should use the GetDriveType function from API func.

   In the case of a CD_ROM it returns an integer (5 i think).

Bye.

Re:Finding/detecting CD-rom drive


Jan Hecker & Rikke Skaanes a crit :

Quote
> Hi,
> I'm making a little program, and needs the program to find/detect the
> drive letter of the cd-rom drive! How's that dine??? I'm usinfg Delphi
> 3.

> Jan

Hello,

   You should use the GetDriveType function from API func.

   In the case of a CD_ROM it returns an integer (5 i think).

Bye.

Other Threads