Solved

Drive Query under XP.

Posted on 2003-11-25
1
173 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 125 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

832 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