Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to test if a floppy is inserted ?
Message
De
14/01/2005 14:41:01
 
 
À
13/01/2005 13:36:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
00976706
Message ID:
00977331
Vues:
17
Here is how we do it:
lcFloppy="A:"
llok=IsFloppyReady()
IF llok	&& disk detected in floppy drive
   *--Ok to proceed check for existing files on floppy
   =ADIR(afiles,lcFloppy+"\*.*")
   IF UPPER(TYPE('afiles'))!="U"
      *etc
   ELSE
      *etc
   ENDIF
ELSE
   *Check drive B:
ENDIF
RETURN

FUNCTION IsFloppyReady

#DEFINE SEM_FAILCRITICALERRORS      1
#DEFINE SEM_NOALIGNMENTFAULTEXCEPT  4
#DEFINE SEM_NOGPFAULTERRORBOX       2
#DEFINE SEM_NOOPENFILEERRORBOX  32768  && 0x8000

DECLARE INTEGER SetErrorMode IN kernel32 INTEGER uMode

LOCAL lvOldOnError, lnVfpError, lnOldErrorMode

* saving the old ErroMode value, and at the same moment
* suppressing a possible system message of no disk in drive
lnOldMode = SetErrorMode (SEM_FAILCRITICALERRORS)

* saving the old ON ERROR state
lvOldOnError = ON("ERROR")
lnVfpError = .F.
ON ERROR lnVfpError = .T.

SET CONS OFF
IF lcFloppy="A:\" .OR. lcFloppy="A:"
	DIR a:
ELSE
	DIR b:
ENDIF
SET CONS ON

* restoring saved properties
ON ERROR &lvOldOnError
= SetErrorMode (lnOldMode)

RETURN  NOT lnVfpError
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform