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.
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.
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.
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
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
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 FindFirstChangeNotificatio n.
Example code:
bool FloppyDiskIsBusy()
{
HANDLE hNotify = FindFirstChangeNotificatio n ( "a:\\", TRUE,
FILE_NOTIFY_CHANGE_FILE_NA ME|
FILE_NOTIFY_CHANGE_DIR_NAM E|
FILE_NOTIFY_CHANGE_ATTRIBU TES|
FILE_NOTIFY_CHANGE_SIZE|
FILE_NOTIFY_CHANGE_LAST_WR ITE);
if (hNotify != INVALID_HANDLE_VALUE)
{
if (WaitForSingleObjectEx(hNo tify,3000, FALSE) == WAIT_TIMEOUT)
return false;
}
return true;
}
Example usuage:
while(FloppyDiskIsBusy())
{
Sleep(1000);
}
Example code:
bool FloppyDiskIsBusy()
{
HANDLE hNotify = FindFirstChangeNotificatio
FILE_NOTIFY_CHANGE_FILE_NA
FILE_NOTIFY_CHANGE_DIR_NAM
FILE_NOTIFY_CHANGE_ATTRIBU
FILE_NOTIFY_CHANGE_SIZE|
FILE_NOTIFY_CHANGE_LAST_WR
if (hNotify != INVALID_HANDLE_VALUE)
{
if (WaitForSingleObjectEx(hNo
return false;
}
return true;
}
Example usuage:
while(FloppyDiskIsBusy())
{
Sleep(1000);
}
ASKER
Axter,
That code works only if I change the 3000 value to 15000
if (WaitForSingleObjectEx(hNo tify,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.
That code works only if I change the 3000 value to 15000
if (WaitForSingleObjectEx(hNo
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?
ASKER
The other executable is creating a set of installation disk.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
HANDLE hFloppy = CreateFile ( "\\\\.\\A:", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
if ( INVALID_HANDLE_VALUE == hFloppy && ERROR_SHARING_VIOLATION == GetLastError ()) {
// assume "busy"
}