Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Check floppy drive busy Win9X

Posted on 2004-08-24
10
Medium Priority
?
228 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:AUDRABRETT7
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 11884540
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"
}
0
 

Author Comment

by:AUDRABRETT7
ID: 11885624
jkr,
That didn't work.

I get an INVALID_HANDLE_VALUE always.

It doesn't matter if the floppy drive is bussy or not.
0
 
LVL 86

Expert Comment

by:jkr
ID: 11885742
Sorry, that was the NT way. 9x requires FILE_SHARE_WRITE to be set, thus defeating the purpose...


0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11885909
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
0
 
LVL 22

Expert Comment

by:grg99
ID: 11886192
>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

0
 
LVL 30

Expert Comment

by:Axter
ID: 11886424
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);
      }
0
 

Author Comment

by:AUDRABRETT7
ID: 11886701
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.
0
 
LVL 30

Expert Comment

by:Axter
ID: 11891074
What exactly is the other process doing to the floppy drive?
0
 

Author Comment

by:AUDRABRETT7
ID: 11893138
The other executable is creating a set of installation disk.
0
 
LVL 30

Accepted Solution

by:
Axter earned 2000 total points
ID: 11893598
One thing you can do is check to see if the disk is full or almost full.
Or you can check the free space available, and then Sleep for a second to see if the free space has change.

That can help you determine if the other process is done.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question