Solved

Floppy Disk Detect

Posted on 2000-02-15
6
256 Views
Last Modified: 2010-04-04
I need to be able to determine if there is a disk in the floppy drive. I want to be able to access the drive but I don't want the generic error "there is no disk in the drive" to come up if a disk is not present, any suggestions please?
0
Comment
Question by:Fitz22
6 Comments
 
LVL 2

Expert Comment

by:Thaddy
ID: 2521994
simply a try except block with an empty except


 
0
 

Accepted Solution

by:
hypereng earned 20 total points
ID: 2522015
You could also use:

If DiskFree(1) < 0 then //'1' for a:
begin
  Application.MessageBox ('No disk in a:', 'Error', MB_OK + MB_IconError);
end;
0
 

Author Comment

by:Fitz22
ID: 2522122
Yeah I tried this already, but calling diskfree causes the application to access the a: drive therefore producing the said error that I don't want to appear, any other suggestions?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:JoeBooth
ID: 2522444
function DiskInDrive(const Drive: char): Boolean;
var
  DrvNum: byte;
  EMode: Word;
begin
  result := false;
  DrvNum := ord(Drive);
  if DrvNum >= ord('a') then dec(DrvNum,$20);
  EMode := SetErrorMode(SEM_FAILCRITICALERRORS);
  try
    if DiskSize(DrvNum-$40) <> -1 then result := true
    else messagebeep(0);
  finally
    SetErrorMode(EMode);
  end;
end;

0
 
LVL 1

Expert Comment

by:bogieman_
ID: 2523471
Just do

chdir('a:\');
if ioresult=1 then There is no disk
else There is a disk

I can't remember if the 1 and 0 are the otherway around though
0
 
LVL 1

Expert Comment

by:bogieman_
ID: 2523479
You may have to do the {$I-} compiler directive to stop an IO error coming up
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unique identifier on a terminal server (rdp) 4 67
tvirtualstringtree freeze when load too manny images 10 73
update joined tables 2 55
enhance the following code 3 37
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 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