Drive Ready Function

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
 
J

Johannes Passing

..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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top