Board index » delphi » How to find out which drive is the cd-rom drive

How to find out which drive is the cd-rom drive

How can I find out which drive is the cd-rom drive? Is there a function in
Delphi?

Thanks for your help

Matthias

 

Re:How to find out which drive is the cd-rom drive


In article <7joqlg$p5...@news.online.de>, matth...@mega-uelzen.de says...

Quote

>How can I find out which drive is the cd-rom drive? Is there a function in
>Delphi?

You can use the API GetDriveType() to determine the type of a drive. This API
can be compibined with another, GetLogicalDriveStrings(), to enumerate all the
available drives on a computer.

To find out more about API functions, search in the Win32 help file (should be
in your delphi help directory).

--
Christo Crause
Thermal Separations Research
University of Stellenbosch
South Africa

Re:How to find out which drive is the cd-rom drive


Matthias,
  GetDriveType. I have  an example on my webpage if you need.

-Dave

Quote
Matthias wrote:

> How can I find out which drive is the cd-rom drive? Is there a function in
> Delphi?

> Thanks for your help

> Matthias

--
David G. Parsons
Inprise Certified Delphi 4 Client/Server Developer
Tekmetrics Certified Delphi Programmer
Tekmetrics Certified Visual Basic 5 Programmer
URL: http://www.erols.com/dparsons
Email: dpars...@erols.com
FAX: (603) 947-8207

Re:How to find out which drive is the cd-rom drive


On Thu, 10 Jun 1999 18:57:51 +0200, "Matthias"

Quote
<matth...@mega-uelzen.de> wrote:
>How can I find out which drive is the cd-rom drive? Is there a function in
>Delphi?

>Thanks for your help

>Matthias

Try this. Found it in here....

Function GetCDDrives : string;
var
  i : integer;
  drvpath : string;
begin
  for i := ord('A') to ord('Z') do begin
    drvpath := chr(i) + ':';
     if GetDriveType(PChar(drvpath)) = DRIVE_CDROM then
          Result:=drvpath;
      end;
end;

Works beautifully.

Jan

Re:How to find out which drive is the cd-rom drive


on Sun, 20 Jun 1999 13:10:39 GMT Jan Hecker confessed:
Quote
>On Thu, 10 Jun 1999 18:57:51 +0200, "Matthias"
><matth...@mega-uelzen.de> wrote:
>>How can I find out which drive is the cd-rom drive? Is there a
>>function in Delphi?

>Try this. Found it in here....

>Function GetCDDrives : string;
>var
>  i : integer;
>  drvpath : string;
>begin
>  for i := ord('A') to ord('Z') do begin
>    drvpath := chr(i) + ':';
>     if GetDriveType(PChar(drvpath)) = DRIVE_CDROM then
>          Result:=drvpath;
>      end;
>end;

>Works beautifully.

According to someone I work with this works ok, as long as the program
is not started from the cdrom you want to detect. Then again, he's using
VB, so YMMV (he does use the same algorithm and GetDriveType API call
though).

Regards, Peter
--
lotteries are simply a tax on the math-impaired portion of our population

Re:How to find out which drive is the cd-rom drive


In article <slrn7msl1n.16ai.pe...@rc.service.rug.nl>, pe...@rc.service.rug.nl

Quote
(Peter R. Fokkinga) writes:
>>Function GetCDDrives : string;
>>var
>>  i : integer;
>>  drvpath : string;
>>begin
>>  for i := ord('A') to ord('Z') do begin
>>    drvpath := chr(i) + ':';
>>     if GetDriveType(PChar(drvpath)) = DRIVE_CDROM then
>>          Result:=drvpath;
>>      end;
>>end;

>>Works beautifully.

On my system W95 + NT4 (ntfs) this function sees the NT drive as a cdrom when
using W95 (ie. it looks like I have two cdroms).

Working on W95: the NT drive is K: and looks like a cdrom and the real cdrom is
L:.

Working on NT: The NT drive is F and the cdrom is L:.

You don't get any errors trying to read the fictitious K cdrom from W95 (not
from run>browse anyway) there's just nothing there.

Just thought it was worth a mention.

Gordon.

May the source be with you

http://members.aol.com/mgcsoft/  (the function junction equation editor)
http://members.aol.com/delphistuf/delphstf.htm   (Delphi bits and bobs and a
few links)

MGCSoft

Re:How to find out which drive is the cd-rom drive


Your function will only return the last CD on the system.

function GetCDDrives : string;

var    c    : char;

begin
result := '';
for c := 'A' to 'Z' do
    begin
    if GetDriveType (pChar (c + ':\')) = DRIVE_CDROM)
    then result := result + c + ',';
    end;
end;

Quote
Jan Hecker <rikke...@get2net.dk> wrote in message

news:376ce827.2857202@Nyheder.get2net.dk...
Quote
> On Thu, 10 Jun 1999 18:57:51 +0200, "Matthias"
> <matth...@mega-uelzen.de> wrote:

> >How can I find out which drive is the cd-rom drive? Is there a function
in
> >Delphi?

> >Thanks for your help

> >Matthias

> Try this. Found it in here....

> Function GetCDDrives : string;
> var
>   i : integer;
>   drvpath : string;
> begin
>   for i := ord('A') to ord('Z') do begin
>     drvpath := chr(i) + ':';
>      if GetDriveType(PChar(drvpath)) = DRIVE_CDROM then
>           Result:=drvpath;
>       end;
> end;

> Works beautifully.

> Jan

Other Threads