Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CD-ROM Ready?
Message
De
22/11/2002 18:34:42
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Divers
Thread ID:
00725983
Message ID:
00726077
Vues:
16
>Let's say that 'e:' is my CD-ROM drive. If there's nothing in there when I execute the following statement:
>
>= ADIR(X, 'E:')
>
>I get an OS error that the CD-ROM drive is not ready. This only happens for Windows XP.
>
>Is there a windows api call I could make to first check to see if the CD-Rom drive is ready? I know that VB has an IsReady() function that handles this, but I can't find anything similar in VFP.
>

Sergey already mentioned the WSH Scripting.FileSystemObject, which is probably the simplest mechanism to use. You can also alter the Windows OS critical error handling to pass through the error rather than trapping it via an API call - the problem you note is not unique to XP, but is common to all NT-family OS versions. the API code looks like:
DECLARE INTEGER SetErrorMode IN KERNEL32.DLL INTEGER ErrorMode
#DEFINE SEM_NOOPENERRORBOX      0x8000
#DEFINE SEM_FAILCRITICALERRORS  0x0001
nOldErrorMode = SetErrorMode( BITOR(SEM_NOOPENERRORBOX,SEM_FAILCRITICALERRORS) )
*
*  Do whatever you need such as ADIR(), FILE(), DIRECTORY()
*
=SetErrorMode(nOldErrorMode)
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