Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
4.83/5 (25 votes)
See more:
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:
MSIL
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
Updated 13-Jan-11 5:29am
v3
Comments
Sergey Alexandrovich Kryukov 11-Jan-11 15:47pm    
Pretty good question. At this moment, I don't know.
Yusuf 11-Jan-11 21:12pm    
Interesting question.

 
Share this answer
 
Comments
Espen Harlinn 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 Rudolf Bihy 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 11-Jan-11 19:03pm    
You do know that that method only returns drive letters and not drive types, right?
 
Share this answer
 
Comments
Manfred Rudolf Bihy 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.
[no name] 16-Jun-11 10:33am    
dfsdf
[no name] 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
[no name] 16-Jun-11 10:34am    
sfadfa
[no name] 16-Jun-11 10:34am    
asdfadfafd
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.
 
Share this answer
 
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.
 
Share this answer
 
Comments
Espen Harlinn 11-Jan-11 16:03pm    
5+ Good one :)
[no name] 11-Jan-11 16:15pm    
Nice idea.
Manfred Rudolf Bihy 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.
Sergey Alexandrovich Kryukov 11-Jan-11 17:19pm    
So, this is indeed WMI?
Good to know, thanks and my 5.
Аslam Iqbal 13-Jan-11 9:36am    
my 5 too

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900