Board index » delphi » How to avoid program halt when changing drive to floppy drive without any floppy disk present

How to avoid program halt when changing drive to floppy drive without any floppy disk present

I have connected a DriveComboBox with a DirectoryListBox.
If I change the drive to a floppy drive without inserting a floppy disk the
program
execution halts.

How do I test whether a floppy disk is present in the drive before I try to
access
the floppy drive?

Thanks for any help.

Frank Krogh

 

Re:How to avoid program halt when changing drive to floppy drive without any floppy disk present


Quote
Frank Krogh wrote:

> How do I test whether a floppy disk is present in the drive before I try to
> access
> the floppy drive?

Create another thread to pre-emptively perform an operation on it.

MH.

--
Martin Harvey. mar...@pergolesi.demon.co.uk
     http://www.pergolesi.demon.co.uk
               ICQ: 37298917

Re:How to avoid program halt when changing drive to floppy drive without any floppy disk present


The message <971961343.986...@helan.trd.sintef.no>
  from  "Frank Krogh" <frank.kr...@unimed.sintef.no> contains these words:

Quote
> I have connected a DriveComboBox with a DirectoryListBox.
> If I change the drive to a floppy drive without inserting a floppy disk the
> program
> execution halts.
> How do I test whether a floppy disk is present in the drive before I try to
> access
> the floppy drive?
> Thanks for any help.
> Frank Krogh

You need to write an event handler for application.onexception.
Use the sender proprty to identify the component (in this case
DirectoryListbox)
and perform appropriate action such as setting the drive back to the last known
working drive.

--
Sincerely,

Andreas Kyriacou
----------------
http://www.andrikkos.co.uk

Re:How to avoid program halt when changing drive to floppy drive without any floppy disk present


Part of the {*word*99} with floppy-drives is that some computers will
hard-freeze in the BIOS for many seconds, either stupidly spinning the
disk-drive motor or just sitting there.

Quote
>Thomas Nelvik wrote:

> Frank Krogh wrote:
> > I have connected a DriveComboBox with a DirectoryListBox.
> > If I change the drive to a floppy drive without inserting a floppy
> disk the
> > program
> > execution halts.

> > How do I test whether a floppy disk is present in the drive before I
> try to
> > access
> > the floppy drive?

> Hi Frank,
> Perhaps you can implement something like this in some event.

> {----------}
> var
>   OrigErrMode: Cardinal;
> begin
>   { Make the system not bother if drive is empty }
>   OrigErrMode := SetErrorMode(SEM_FAILCRITICALERRORS);
>   { ... try access the empty drive ... }
>   { Restore ErrorMode }
>   SetErrorMode(OrigErrMode);
> end;
> {----------}

> HTH
> Regards
> -ThomasN

--
------------------------------------------------------------------
Sundial Services :: Scottsdale, AZ (USA) :: (480) 946-8259
mailto:i...@sundialservices.com  (PGP public key available.)

- Show quoted text -

Quote
> Fast(!), automatic table-repair with two clicks of the mouse!
> ChimneySweep(R):  "Click click, it's fixed!" {tm}
> http://www.sundialservices.com/products/chimneysweep

Re:How to avoid program halt when changing drive to floppy drive without any floppy disk present


Quote
Frank Krogh wrote:
> I have connected a DriveComboBox with a DirectoryListBox.
> If I change the drive to a floppy drive without inserting a floppy
disk the
> program
> execution halts.

> How do I test whether a floppy disk is present in the drive before I
try to
> access
> the floppy drive?

Hi Frank,
Perhaps you can implement something like this in some event.

{----------}
var
  OrigErrMode: Cardinal;
begin
  { Make the system not bother if drive is empty }
  OrigErrMode := SetErrorMode(SEM_FAILCRITICALERRORS);
  { ... try access the empty drive ... }
  { Restore ErrorMode }
  SetErrorMode(OrigErrMode);
end;
{----------}

HTH
Regards
-ThomasN

Re:How to avoid program halt when changing drive to floppy drive without any floppy disk present


Thanks for the suggestions.

By a coincidence I was lucky and found a very nice article written by
Grahame Marsh:
Learning To Drive, Unofficial Newsletter of Delphi Users - Issue #20 - March
1997

Re:How to avoid program halt when changing drive to floppy drive without any floppy disk present


Quote
Arminio Grgic wrote:
> This is OK but you need one more thing because this wont help on NT
> machines where you will still get syste,m prompter that will inform
> you  that drive is inaccessible. So, put at the beginning of oyur code
> (it can stays in DPR file) following:

> seterrormode(SEM_NOOPENFILEERRORBOX or SEM_FAILCRITICALERRORS);

> This will turn off prompters for critical errors and errors during
> openning file on NT ...

.. and -even then-, I am convinced, on certain hardware you may -still-
experience unexpected "hard waits."  I have seen exactly the same
program behave differently on different machines.

Re:How to avoid program halt when changing drive to floppy drive without any floppy disk present


Quote
>You need to write an event handler for application.onexception.
>Use the sender proprty to identify the component (in this case
>DirectoryListbox)
>and perform appropriate action such as setting the drive back to the last known
>working drive.
>Sincerely,
>Andreas Kyriacou
>----------------
>http://www.andrikkos.co.uk

This is OK but you need one more thing because this wont help on NT
machines where you will still get syste,m prompter that will inform
you  that drive is inaccessible. So, put at the beginning of oyur code
(it can stays in DPR file) following:

seterrormode(SEM_NOOPENFILEERRORBOX or SEM_FAILCRITICALERRORS);    

This will turn off prompters for critical errors and errors during
openning file on NT ...

Arminio.Gr...@USA.Net
http://www.geocities.com/SiliconValley/Way/9629/arminio.htm

Re:How to avoid program halt when changing drive to floppy drive without any floppy disk present


Yes, on my DELL Latitude CP you will still experience a hardware wait,
on my DELL Latitude CPi and Compaq Armada you won't.

Nick

Quote
>.. and -even then-, I am convinced, on certain hardware you may -still-
>experience unexpected "hard waits."  I have seen exactly the same
>program behave differently on different machines.

---
Nick.R...@Bigfoot.Com
http://www.bigfoot.com/~nick.roux

"The Earth is too small and fragile a basket
 for Humankind to keep all its' eggs in"
                      Unknown SETI@home user

Other Threads