Solved

Floppy Disk Detect

Posted on 2000-02-15
6
253 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
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.

 
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

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
A short film showing how OnPage and Connectwise integration works.
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 …

932 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

10 Experts available now in Live!

Get 1:1 Help Now