Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Check floppy drive busy Win9X

Posted on 2004-08-24
10
Medium Priority
?
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

722 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