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

x
?
Solved

Drive Query under XP.

Posted on 2003-11-25
1
Medium Priority
?
181 Views
Last Modified: 2010-04-05
How can I query if there is media in the A: or B: drive without triggering XP to prompt No Disk when the drive is empty?

DiskFree and DiskSize both cause XP to put up the No Disk dialog. (Interesting sidenote, it doesn't promt when running in the debugger in delphi).
0
Comment
Question by:BJThomsen
1 Comment
 
LVL 8

Accepted Solution

by:
gmayo earned 500 total points
ID: 9820966
For some reason, the floppy drive is completely dumb when it comes to knowing whether there is a disk in there or not. It has to try to access it before telling you whether it is there or not.

There is a previous question on this:
http://oldlook.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20008825.html
I tried to look at the link (http://www.delphi3000.com/articles/article_1171.asp) which apparently has your answer, however my Intenet connection is playing up and I can't access it.

Also, the following seems to work (D7, XP Home):
procedure TForm1.Button1Click(Sender: TObject);
  function DiskInDrive(Drive: Char): Boolean ;
 var
   ErrorMode: word ;
 begin
   Drive := UpCase(Drive) ;
   if not (Drive in ['A'..'Z']) then
     raise EConvertError.Create('Not a valid drive ID') ;
   ErrorMode := SetErrorMode(SEM_FailCriticalErrors) ;

   try
     if DiskSize(Ord(Drive) - $40) = -1 then
       DiskInDrive := False
     else
       DiskInDrive := True ;
   finally
     SetErrorMode(ErrorMode) ;
   end;
 end;
begin
      if DiskInDrive('A') = false then begin
            ShowMessage('No floppy');
      end;
end;

(Credit to http://oldlook.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10137545.html)

Geoff M.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

824 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