Solved

Floppy Disk Detect

Posted on 2000-02-15
6
255 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

810 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