Solved

Drive Query under XP.

Posted on 2003-11-25
1
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
When I am typing into a TEdit last word repeats 7 175
Help on project with Soap 10 68
Delphi 2 89
Browsing a TTreeView in Delphi 5 46
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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