Click here to Skip to main content
Sign Up to vote bad
good
See more: CWindowsAPI
Hello, guys
I use GetDriveType function to determine CD-ROM drives in a computer, but I want to detect the writable ones, using windows API, I searched DeviceIoControl function but the documentation was very comprehensive and I was unable to get my answer. Can anyone help me?
Thanks in advance
mr.abzadeh
 
EDIT: I found that the DEVICE_MEDIA_INFO structure contains a
DWORD  MediaCharacteristics;
member that clearly specifies if the media is Writable, by I can not find which function returns it.
 
EDIT: I got the DEVICE_MEDIA_INFO structure for both CD-ROM and CD-RW and examined the MediaCharacteristics member, showing no difference, so DEVICE_MEDIA_INFO may not contain writable characteristic of a cd-rom drive.
Posted 22 Jan '13 - 0:34
Edited 22 Jan '13 - 3:19

Comments
Richard MacCutchan - 22 Jan '13 - 9:33
Did you have a CD mounted in the drive at the time you ran the test?
mr.abzadeh - 22 Jan '13 - 10:19
Yes, there was a CD in the drive for both CD-ROM and CD-RW.
Richard MacCutchan - 22 Jan '13 - 10:22
See my Solution comments below.

2 solutions

Possibly you may use IMAPI, namely IDiscRecorder::QueryMediaType[^] method. See also CD Burning and Device Discovery with IMAPI[^]
  Permalink  
Comments
mr.abzadeh - 22 Jan '13 - 10:43
I tested ICDBurn Interface, and It worked correctly, Thanks for your help. If one day you found a way to detect recordable cd drives directly, without ICDBurn or IMAPI, please send it to me. Thanks again mr.abzadeh
CPallini - 22 Jan '13 - 12:44
You are welcome.
I just tested this on my system and it shows the correct characteristics for the drive when a Writable CD/DVD is mounted. Note that the GET_MEDIA_TYPES[^] structure contains an array of DEVICE_MEDIA_INFO[^] entries, so you need to iterate the list for the correct entry.
  Permalink  
Comments
mr.abzadeh - 22 Jan '13 - 10:31
I examined it for both CD-ROW and CD-RW, with CD mounted, and the value of MediaCharacteristics in the second item of array was MEDIA_READ_WRITE, i.e. pMediaType->MediaInfo[1].DeviceSpecific.DiskInfo.MediaCharacteristics was 8. my code is as this: /*-------------------------------------*/ static int uIsMediaWritable( const GET_MEDIA_TYPES * pMediaType ) { unsigned uCount = pMediaType->MediaInfoCount; for ( unsigned uIndex = 0 ; uIndex < uCount ; uIndex ++ ) { DWORD dwMediaCharacteristics = pMediaType->MediaInfo[uIndex].DeviceSpecific.DiskInfo.MediaCharacteristics; if ( dwMediaCharacteristics & MEDIA_READ_WRITE ) return TRUE; if ( dwMediaCharacteristics & MEDIA_WRITE_ONCE ) return TRUE; //if ( dwMediaCharacteristics & MEDIA_WRITE_PROTECTED ) return TRUE; } return FALSE; }
Richard MacCutchan - 22 Jan '13 - 10:42
So that is good then?
mr.abzadeh - 22 Jan '13 - 14:16
No, It reported that CD DRIVE is recordable for both CD-ROW and CD-RW drives, which is not correct.

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 293
1 Sergey Alexandrovich Kryukov 143
2 Mohammed Hameed 123
3 Santhosh G_ 108
4 Lohith Korupolu 85
0 Sergey Alexandrovich Kryukov 8,266
1 OriginalGriff 6,306
2 CPallini 3,528
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid