Link to home
Start Free TrialLog in
Avatar of AUDRABRETT7
AUDRABRETT7

asked on

Check floppy drive busy Win9X

On a Win9x OS, how can I check if the floppy drive is busy?

I have a program monitoring another process, and I need to be able to determine when the other executable is done process files on a floppy disk.
Avatar of jkr
jkr
Flag of Germany image

Try to

HANDLE hFloppy = CreateFile ( "\\\\.\\A:", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);

if ( INVALID_HANDLE_VALUE == hFloppy && ERROR_SHARING_VIOLATION == GetLastError ()) {

    // assume "busy"
}
Avatar of AUDRABRETT7
AUDRABRETT7

ASKER

jkr,
That didn't work.

I get an INVALID_HANDLE_VALUE always.

It doesn't matter if the floppy drive is bussy or not.
Sorry, that was the NT way. 9x requires FILE_SHARE_WRITE to be set, thus defeating the purpose...


You can try with GetVolumeInformation, but I have not tried what happens if floppy drive is bussy (maybe can return with cached information)

http://msdn.microsoft.com/library/en-us/fileio/base/getvolumeinformation.asp
>On a Win9x OS, how can I check if the floppy drive is busy?

Probably not doable in the way you're thinking.

Can you wrap the other program in a batch file that does:


echo "BUSY" >A:\BusyFile
TheProgram
del A:\BusyFile

You can try using FindFirstChangeNotification.

Example code:
bool FloppyDiskIsBusy()
{
      HANDLE hNotify = FindFirstChangeNotification ( "a:\\", TRUE,
            FILE_NOTIFY_CHANGE_FILE_NAME|
            FILE_NOTIFY_CHANGE_DIR_NAME|
            FILE_NOTIFY_CHANGE_ATTRIBUTES|
            FILE_NOTIFY_CHANGE_SIZE|
            FILE_NOTIFY_CHANGE_LAST_WRITE);
      if (hNotify != INVALID_HANDLE_VALUE)
      {
            if (WaitForSingleObjectEx(hNotify,3000,FALSE) == WAIT_TIMEOUT)
                  return false;
      }
      return true;
}


Example usuage:
      while(FloppyDiskIsBusy())
      {
            Sleep(1000);
      }
Axter,

That code works only if I change the 3000 value to 15000
if (WaitForSingleObjectEx(hNotify,15000,FALSE) ==

But then there's a 15 second delay for the results when the other program is finish processing.

Since this is better then nothing, I'll use it if no one else has a better suggestion.
What exactly is the other process doing to the floppy drive?
The other executable is creating a set of installation disk.
ASKER CERTIFIED SOLUTION
Avatar of Axter
Axter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial