?
Solved

Floppy Disk Detect

Posted on 2000-02-15
6
Medium Priority
?
263 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
[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
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 40 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

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.

Question has a verified solution.

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

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…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

800 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