Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking If Drive A: Is Ready
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00704042
Message ID:
00704357
Vues:
19
>How do I determine if drive A: has a disk in it>
>
>I tried this code, but the error handler fails
>to trap the error
>
>ON ERROR MESSAGEBOX(ERROR())
>ADIR(a, "a:")
>ON ERROR

The easiest way to get around the error is to disable the OS from intercepting it. Try:
DECLARE INTEGER SetErrorMode IN WIN32API INTEGER ErrorMode
#define SEM_NOOPENFILEERRORBOX      0x8000
#define SEM_FAILCRITICALERRORS      0x0001
nErrorModeOld = SetErrorMode(SEM_NOOPENFILEERRORBOX + SEM_FAILCRITICALERRORS)
IF DISKSPACE('A:') <= 0
   ? 'No Disk'
   * No A: disk
ENDIF
=SetErrorMode(nErrorModeOld)
A better way is to use the WSH FileSystemObject's IsReady method:
oFSO = CREATEOBJ('Scripting.FileSystemObject')
oDrive = oFSO.GetDrive('A:')
? oDrive.IsReady()
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform