Solved

Drive Query under XP.

Posted on 2003-11-25
1
171 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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

14 Experts available now in Live!

Get 1:1 Help Now