Board index » cppbuilder » Which drive is CD drive ?

Which drive is CD drive ?

How to detect which of the drives on the computer is a CD drive (c:\, d:\) ?

Thanks.

VP

 

Re:Which drive is CD drive ?


Hi VP,

Quote
> How to detect which of the drives on the computer is a CD drive (c:\, d:\) ?

You can iterate over the possible drive letters, using the
GetDriveType() API function to retrieve the corresponding drive type.
You're looking for the DRIVE_CDROM return value.

Good luck!

Damon

Re:Which drive is CD drive ?


Damon,

what do you use to iterate over the possible drive letters ?

VP

Quote
Damon Chandler <dm...@cornell.edu> wrote in message

news:386710A2.96465D57@cornell.edu...
Quote
> Hi VP,
> > How to detect which of the drives on the computer is a CD drive (c:\,
d:\) ?

> You can iterate over the possible drive letters, using the
> GetDriveType() API function to retrieve the corresponding drive type.
> You're looking for the DRIVE_CDROM return value.

> Good luck!

> Damon

Re:Which drive is CD drive ?


Quote
: "VP" <VP_no_sp...@software66.com> wrote:
>what do you use to iterate over the possible drive letters ?

An integer. At the same time, have a bit mask running with that.

--
General information:
  * Post to the right group - http://www.borland.com/newsgroups/
    * Do not cross- or multipost
      * Research at http://www.mers.com/searchsite.html

Stefan Hoffmeister - http://www.econos.de/
(TeamB - http://www.teamb.com/)

Re:Which drive is CD drive ?


Damon,

is there any "more elegant" way to acomplish that instead of doing something
like this:

  static char * Drive_Letter[]={"a:\\","b:\\","c:\\","d:\\","e:\\","f:\\",
      "g:\\","h:\\","i:\\","j:\\","k:\\","l:\\","m:\\","n:\\","o:\\","p:\\",

"q:\\","r:\\","s:\\","t:\\","u:\\","v:\\","w:\\","x:\\","y:\\","z:\\"};

     for(int x =0; x <= 25; x++ )
      {
        switch(GetDriveType(Drive_Letter[x]))
          {
              case DRIVE_CDROM:
                // HERE IT IS !!!
              break;
            }
        }

VP

Quote
Damon Chandler <dm...@cornell.edu> wrote in message

news:386710A2.96465D57@cornell.edu...
Quote
> Hi VP,
> > How to detect which of the drives on the computer is a CD drive (c:\,
d:\) ?

> You can iterate over the possible drive letters, using the
> GetDriveType() API function to retrieve the corresponding drive type.
> You're looking for the DRIVE_CDROM return value.

> Good luck!

> Damon

Re:Which drive is CD drive ?


In a quick search of deja.com I found the following response from Matt Arnold to
the question "How to find out which drive letters are valid ?"

http://x37.deja.com/=dnc/[ST_rn=ps]/getdoc.xp?AN=443287291&CONTEXT=946309429.1732968472&hitnum=10

You should be able to use this code to extract what you need.

It's not a bad idea to try a search on deja.com (use the advanced search mode)
before asking in the newsgroup. Then a question can be formulated which will get
closer to the heart of the matter.

Hope this helps.
Claude

Quote
VP wrote:
> How to detect which of the drives on the computer is a CD drive (c:\, d:\) ?

> Thanks.

> VP

Re:Which drive is CD drive ?


Great example.

Thanks !

VP

Quote
Claude <claude_at_newbie_dot_...@oro.net> wrote in message

news:38678BE7.80A733A9@oro.net...
Quote
> In a quick search of deja.com I found the following response from Matt
Arnold to
> the question "How to find out which drive letters are valid ?"

http://x37.deja.com/=dnc/[ST_rn=ps]/getdoc.xp?AN=443287291&CONTEXT=946309429
.1732968472&hitnum=10
Quote

> You should be able to use this code to extract what you need.

> It's not a bad idea to try a search on deja.com (use the advanced search
mode)
> before asking in the newsgroup. Then a question can be formulated which
will get
> closer to the heart of the matter.

> Hope this helps.
> Claude

> VP wrote:

> > How to detect which of the drives on the computer is a CD drive (c:\,
d:\) ?

> > Thanks.

> > VP

Re:Which drive is CD drive ?


There is an entry in the registry that seems to flag the CDROM

        HKEY_LOCAL_MACHINE\SYSTEM\DISK\Device\cdrom0

It has the letter of the CD ROM.

This is true on the NT machines that I am using.

Quote
Damon Chandler wrote in message <386710A2.96465...@cornell.edu>...
>Hi VP,
>> How to detect which of the drives on the computer is a CD drive (c:\,
d:\) ?

>You can iterate over the possible drive letters, using the
>GetDriveType() API function to retrieve the corresponding drive type.
>You're looking for the DRIVE_CDROM return value.

>Good luck!

>Damon

Re:Which drive is CD drive ?


Better use GetLogicalDrives to get all drive letters.

The DWORD return value will contain a bit per drive which is set to 0 or 1.
(1 means present).

drive A is bit 0, drive B is bit 1 and so on.

(All you do is to shift right once for each drive letter).

/Anders

Quote
"VP" <VP_no_sp...@software66.com> wrote in message

news:8481jv$h7s8@forums.borland.com...
Quote
> Damon,

> is there any "more elegant" way to acomplish that instead of doing
something
> like this:

>   static char * Drive_Letter[]={"a:\\","b:\\","c:\\","d:\\","e:\\","f:\\",

"g:\\","h:\\","i:\\","j:\\","k:\\","l:\\","m:\\","n:\\","o:\\","p:\\",
Quote

> "q:\\","r:\\","s:\\","t:\\","u:\\","v:\\","w:\\","x:\\","y:\\","z:\\"};

>      for(int x =0; x <= 25; x++ )
>       {
>         switch(GetDriveType(Drive_Letter[x]))
>           {
>               case DRIVE_CDROM:
>                 // HERE IT IS !!!
>               break;
>             }
>         }

> VP

> Damon Chandler <dm...@cornell.edu> wrote in message
> news:386710A2.96465D57@cornell.edu...
> > Hi VP,
> > > How to detect which of the drives on the computer is a CD drive (c:\,
> d:\) ?

> > You can iterate over the possible drive letters, using the
> > GetDriveType() API function to retrieve the corresponding drive type.
> > You're looking for the DRIVE_CDROM return value.

> > Good luck!

> > Damon

Other Threads