🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.misc
Article #272

Re: Finding/detecting CD-rom drive

#272
From: Jason Wallace
Date: Mon, 26 Apr 1999 00:00
59 lines
2255 bytes
  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
DarkElf@SLSoftware.reno.nv.us
--
"We are Microsoft.  Resistance is Futile.  You will be assimilated.
--


Jan Hecker & Rikke Skaanes <rikkejan@get2net.dk> wrote in message
news:3722E2CD.5347E78@get2net.dk...
> 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
>
Technical Details
Message-ID: <37240deb@news.greatbasin.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3722E2CD.5347E78@get2net.dk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 104e31,760af54ae7896609
X-Google-Attributes: gid104e31,public
X-Google-Thread: 10baee,760af54ae7896609
X-Google-Attributes: gid10baee,public
X-Google-Thread: f894d,760af54ae7896609
X-Google-Attributes: gidf894d,public
From: "Jason Wallace" <DarkElf@SLSoftware.reno.nv.us>
Subject: Re: Finding/detecting CD-rom drive
Date: 1999/04/26
Message-ID: <37240deb@news.greatbasin.net>
X-Deja-AN: 470937702
References: <3722E2CD.5347E78@get2net.dk>
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Trace: 25 Apr 1999 23:55:39 -0700, rno-max3-44.gbis.net
Organization: SL Software
Reply-To: "Jason Wallace" <DarkElf@SLSoftware.reno.nv.us>
Newsgroups: comp.lang.pascal.delphi.misc,borland.public.delphi,comp.lang.pascal.delphi