Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C#
Dear friends:
I searched the internet and could not find a way to programmatically know whether a disk drive supports DVD or only CD without the need to insert a disk media into the drive. I have tried WMI unsuccessfully before. Windows operating system can display cdrom or dvd drive information correctly. C++, C# or VB solutions are all welcome! Thanks in advance!
 
Modification
One more thing:
I tested the registry on two machines: one with a DVD+-RW and another with a CD-RW. Both of the machines have DefaultDvdRegion = 1 in the registry although one machine has only CD-RW.
The Name and DeviceID of the ManagementObject do reflect the type of the drive:
DVD+-RW has this: "IDE\\CDROMTSSTCORP_DVD+-RW_TS-H653B_______________D200____\\5&1A4D1015&0&0.0.0"
 
CD-RW has this  : "IDE\\CDROMTSSTCORP_CD-RW___TS-H292B_______________DE03____\\5&70107E7&0&0.0.0"
 
End Modification
Posted 11-Jan-11 9:42am
gshen551
Edited 13-Jan-11 5:29am
v3
Comments
SAKryukov at 11-Jan-11 15:47pm
   
Pretty good question. At this moment, I don't know.
Yusuf at 11-Jan-11 21:12pm
   
Interesting question.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The only way I know to do this would be to get the WMI Win32_CDROMDrive instances on the machine, then check for DVD in the Name or DeviceId properties.
 
You may even have to go so far as to get the DeviceID from the isntance then check in the Registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\[DeviceIdHere]\Device Parameters, then check for the existance of a value named "DefaultDvdRegion". This won't exist for CDROM drives, but does for DVD drives.
  Permalink  
Comments
Espen Harlinn at 11-Jan-11 16:03pm
   
5+ Good one :)
Thaddeus Jones at 11-Jan-11 16:15pm
   
Nice idea.
Manfred R. Bihy at 11-Jan-11 17:11pm
   
Moved from answer:
Friends, thanks!
 
Answer 1 from Dave Kreskowiak is the best solution (also simple) I could find so far. ("The only way I know to do this would be to get the WMI Win32_CDROMDrive instances on the machine, then check for DVD in the Name or DeviceId properties..."). Quite a few people might be interested in this solution.
SAKryukov at 11-Jan-11 17:19pm
   
So, this is indeed WMI?
Good to know, thanks and my 5.
Aslam_Iqbal at 13-Jan-11 9:36am
   
my 5 too
Manfred R. Bihy at 13-Jan-11 11:29am
   
Good call! 5+
Praveen Meghwal at 16-Aug-11 6:46am
   
My 5 too
onurag19 at 11-May-12 4:00am
   
my 5+ too
Gihan Liyanage at 29-Aug-14 0:53am
   
Good Idea..
digimanus at 29-Aug-14 8:39am
   
My 5 too
Gihan Liyanage at 3-Sep-14 2:31am
   
Good Solution for uncommon problem.. My 5+
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Comments
Espen Harlinn at 11-Jan-11 16:07pm
   
And how can that be used to determine if it's a CD drive or a DVD drive? That's like saying that System.Threading.Timer sends WM_TIMER messages :)
Manfred R. Bihy at 11-Jan-11 17:11pm
   
Moved from answer:
Friends, thanks!
 
Answer 1 from Dave Kreskowiak is the best solution (also simple) I could find so far. ("The only way I know to do this would be to get the WMI Win32_CDROMDrive instances on the machine, then check for DVD in the Name or DeviceId properties..."). Quite a few people might be interested in this solution.
Dave Kreskowiak at 11-Jan-11 19:03pm
   
You do know that that method only returns drive letters and not drive types, right?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

  Permalink  
Comments
Manfred R. Bihy at 13-Jan-11 10:15am
   
Moved from answer:
 
Answer 5 is more direct and reliable. I tried. The c++ program can directly return the FILE_DEVICE_DVD (type of GET_MEDIA_TYPES) constant rather than having to extract the substring "DVDxx" or "CDROM" from the device ID or device name. It does not rely on the description part of the device name or ID because the description is not standardized and may change later.
 
Thank you, Mr. Randor and Delaune.
hyo jeong jeon at 16-Jun-11 10:33am
   
dfsdf
Randor at 15-Jan-11 4:45am
   
I was contacted by a member here regarding this code sample. You have my apology for the poorly written and leaky code sample. I have updated the sample.
 
Best Wishes,
-David Delaune
hyo jeong jeon at 16-Jun-11 10:34am
   
sfadfa
hyo jeong jeon at 16-Jun-11 10:34am
   
asdfadfafd
hyo jeong jeon at 16-Jun-11 10:34am
   
sdfsdfsdf
hyo jeong jeon at 16-Jun-11 10:34am
   
asdfadsf
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

Not sure in C, C++. But in C#, we can easily fetch this info using DriveInfo class of System.IO package/namespace. It has various useful property, out of which DriveType indicates whether a drive is any of: CDRom, Fixed, Unknown, Network, NoRootDirectory, Ram, Removable, or Unknown. Values are listed in the DriveType enumeration.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.141022.2 | Last Updated 29 Aug 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100