Solved

Drive Query under XP.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

12 Experts available now in Live!

Get 1:1 Help Now