Solved

Floppy Disk Detect

Posted on 2000-02-15
6
251 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

17 Experts available now in Live!

Get 1:1 Help Now