Solved

Disk Check Question

Posted on 2002-06-11
4
200 Views
Last Modified: 2010-04-02
Guys...

I am writing an application, where I have to check if a floppy disk drive is ready with a disk in it.
What is the method I should use?

I would consider any C/Java/Ada code snippets to see how this can be done.

Thanks
prain
0
Comment
Question by:prain
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 50 total points
ID: 7069751
Under Win32:

Call 'GetVolumeInformation()' for the floppy drive

Under UN*X:

Call 'statfs()' for the respective mount point
0
 
LVL 4

Expert Comment

by:mblat
ID: 7070074
That is code snippet:

bool IsFloppyInserted()
{
    UINT uOldStatus = SetErrorMode(SEM_FAILCRITICALERRORS);
     bool bStatus = false;
     
     /* Save current drive and directory. */
     int nCurdrive = _getdrive();        // Get current drive
     TCHAR buffer[_MAX_PATH];
     _tgetcwd(buffer, _MAX_PATH);

     /* If we can switch to the drive, it exists. */
     if(!_chdrive(1))
          bStatus = true;
     
     /* Restore original drive.*/
     _chdrive(nCurdrive);                // Restore OLD drive
     _tchdir(buffer);                      // Restore OLD directory
    SetErrorMode(uOldStatus);
     
     return bStatus;
}

Hope it helps...
0
 
LVL 11

Expert Comment

by:griessh
ID: 7262245
Dear prain

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "jkr"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7332929
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

776 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