Solved

Check floppy drive busy Win9X

Posted on 2004-08-24
10
222 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
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.

 
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 500 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

828 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