Solved

Check floppy drive busy Win9X

Posted on 2004-08-24
10
219 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
Comment Utility
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
Comment Utility
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
Comment Utility
Sorry, that was the NT way. 9x requires FILE_SHARE_WRITE to be set, thus defeating the purpose...


0
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
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
Comment Utility
>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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 30

Expert Comment

by:Axter
Comment Utility
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
Comment Utility
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
Comment Utility
What exactly is the other process doing to the floppy drive?
0
 

Author Comment

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

Accepted Solution

by:
Axter earned 500 total points
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now