Drive Ready Function

  • Thread starter Thread starter DosFreak
  • Start date Start date
D

DosFreak

I downloaded a file manager example with drives being listed and
supposing E: was a cdrom, how do you that e: is ready? is there a win32
function to tell you that it is ready for reading without doing a
physical read, and having it pop up with insert a disk.
Or maybe I have to do it that way.

Marc
 
..Net provides DriveInfo.IsReady for that purpose.

Win32 itself does not provide a specific function for this. A common way
to do such a check (in fact, that is also how DriveInfo.IsReady does it)
is as follows: Call SetErrorMode to disable the disk error dialogs, call
GetFileAttributes on the drive path to do the actual check and finally
reenable error dialogs with SetErrorMode.

Of course, GetFileAttributes may block, so calling it asynchronously
might be agood idea. Furthermore, SetErrorMode has process-wide effects,
so you may run into race conditions here.

--Johannes
 
Back
Top