Board index » delphi » Help needed: Check for floppy in disk drive?

Help needed: Check for floppy in disk drive?

My problem: How to check whether a floppy disk (formatted) is in
the floppy disk drive without getting the "Abort/Retry" window?

I'd like to do this with Delphi 1 and Windows 3.1.

Under DOS I used an own Int24-Handler (a code array). I assigned
its address to the interrupt vector location. This results in a
GPF under Win 3.1. Any help is appreciated!
 ____________________________________________
| Steffen Hauptmann                          |
| phone:  +49 241 6003-538                   |
| fax:    +49 241 6003-518                   |
| e-mail: haupt...@pfa.research.philips.com  |
|____________________________________________|

 

Re:Help needed: Check for floppy in disk drive?


In article <31BE8CCC.41C67...@pfa.research.philips.com>
           haupt...@pfa.research.philips.com "Hauptmann" writes:

Quote
> My problem: How to check whether a floppy disk (formatted) is in
> the floppy disk drive without getting the "Abort/Retry" window?

> I'd like to do this with Delphi 1 and Windows 3.1.

> Under DOS I used an own Int24-Handler (a code array). I assigned
> its address to the interrupt vector location. This results in a
> GPF under Win 3.1. Any help is appreciated!

Hi,

Could you use a try...except block to trap the gpf?

Mike

Re:Help needed: Check for floppy in disk drive?


Quote
Mayes uk <m...@d-m-g.demon.co.uk> wrote:
>In article <31BE8CCC.41C67...@pfa.research.philips.com>
>           haupt...@pfa.research.philips.com "Hauptmann" writes:
>> My problem: How to check whether a floppy disk (formatted) is in
>> the floppy disk drive without getting the "Abort/Retry" window?

>> I'd like to do this with Delphi 1 and Windows 3.1.

>> Under DOS I used an own Int24-Handler (a code array). I assigned
>> its address to the interrupt vector location. This results in a
>> GPF under Win 3.1. Any help is appreciated!

I don't remember where I got this code, but it works fine for EXACTLY
what you want to do.  I pulled it from a DLL I have, so you may have
to change the FUNCTION line to fit your needs, but otherwise it
completely functional.  

SYNTAX:

if DiskExists('A') = True then

function DiskExists(Drive: Char): Boolean;export;
var
  ErrorMode: Word;
begin
  Drive := UpCase(Drive);
  { Make sure drive is a valid letter }
  if not (Drive in ['A'..'Z']) then
    raise EConvertError.Create('Not a valid drive letter');
  { Turn off critical errors }
  ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
  try
    Application.ProcessMessages;
    Result := (DiskSize(Ord(Drive) - Ord('A') + 1) <> -1);
  finally
    { Restore the old error mode }
    SetErrorMode(ErrorMode);
    Application.ProcessMessages;
  end;
end;

Re:Help needed: Check for floppy in disk drive?


Quote
> bard-d...@utech.net (Stone) wrote in article

<31c06f6...@news.utech.net>...
Quote

> I don't remember where I got this code, but it works fine for EXACTLY
> what you want to do.  I pulled it from a DLL I have, so you may have
> to change the FUNCTION line to fit your needs, but otherwise it
> completely functional.  

[snip]

The code you posted was a function I had posted a while back when this
question was asked...  I noticed a few days ago that it has also been
picked up by the SWAG archive.  This makes me very happy to see people
using (and reposting even) some of my code.  (I'm sitting here with a big
grin on my face, if any of my co-workers should look into my cubicle,
they'll think I've lost it...)

--
David S. Becker
ADP Dealer Services (Plaza R&D)
mailto:d...@plaza.ds.adp.com
(503) 402-3236

Other Threads