Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to query the registry with WScript.Shell
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00571288
Message ID:
00571361
Vues:
17
>>Running the following code result in an error if the key "Users" doesn't exist in the registry.
>>
>>goWsHost = CreateObject("WScript.Shell") && initiate Windows Scripting Host
>>
>>REGKEY_LOC = "HKEY_CURRENT_USER\Software\Ifö Ceramics AB\PiDoc\1.0\Window Positions\Users"
>>
>>* Next line gives an error saying it can not open the registry key.
>>lcBuffer = goWsHost.RegRead(REGKEY_LOC)
>>
>>Well i understand that it can not, but how can i query the registry to check for the existance of the key or att least avoid the error message ?
>
>I'd opt for dealing with the registry using the registry class that comes with VFP. There's a method that will allow you to test for the presence of the key prior to trying to read from it. The WSH's registry functions, while easy to use, are much less flexible than the registry class.
>
>BTW, the five individual hives can be abbreviated. In this case the abbreviation would be HKCU.

>> Hi George,
Well i have just started to look into the Windows Scripting Host and i think the methods for manipulating the registry seemes easy to use. I just dont understand how the "architect" of this "Registry-methods" could have overlooked the need of testing for the existance of a key before trying to read from it or getting some special return value if the key doesnt exist.I am sure that the use of FFC's registry classes is far more flexible.

/Torgny
/Torgny
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform