(Applicable à Windows)
La fonction RegOpenKey ouvre la clé de registre spécifiée.
Format de la fonction :
RegOpenKey(hKey as Integer, subkey as String) as Integer
Identifie une clé ouverte ou une clé prédéfinie. Le paramètre hKey peut avoir l'une des valeurs prédéfinies suivantes :
HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
Identifie la clé à ouvrir. Subkey doit être une sous-clé de la clé identifiée par le paramètre hKey. Si subkey est une chaîne vide, la fonction renvoie la même clé que celle spécifiée par hKey.
En cas de réussite, la fonction renvoie un descripteur vers la clé de registre qui vient d'être ouverte. Dans le cas contraire, elle renvoie 0.
Exemple :
Dim hkey1, hkey2, hkey3 as integer
Dim cBuf as string
Dim ccBuf[47] as char
Dim bBuf[100] as byte
Dim i as integer
ClrScr()
for i = 0 to 99
bBuf[i] = i
next i
cBuf = "1234567890ßqwertzuiopü+asdfghjklöä#<yxcvbnm,.-"
ccBuf = cBuf
hkey1 = RegOpenKey(HKEY_LOCAL_MACHINE, "LOGICIEL")
if hkey1 = 0 then
Print("Echec de RegOpenKey.")
quitter
endif
hkey2 = RegCreateKey(hkey1, "CA")
if hkey2 = 0 then
Print("Echec de RegCreateKey 1.")
quitter
endif
if Not(RegSetValue(hkey1, "CA", "Sarl Paderborn - Allemagne")) then
Print("Echec de RegSetValue")
endif
hkey3 = RegCreateKey(hkey2, "pour test uniquement")
if hkey3 = 0 then
Print("Echec de RegCreateKey 2.")
quitter
endif
if Not(RegSetVariable(hkey3, "var_1", 123)) then
Print("Echec de RegSetVar 1.")
endif
if Not(RegSetVariable(hkey3, "var_2", "Chaîne")) then
Print("Echec de RegSetVar 2.")
endif
if Not(RegSetVariable(hkey3, "var_3", cBuf, 46)) then
Print("Echec de RegSetVar 3.")
endif
if Not(RegSetVariable(hkey3, "var_4", bBuf, 100)) then
Print("Echec de RegSetVar 4.")
endif
if Not(RegSetVariable(hkey3, "var_5", cBuf, 46, REG_SZ)) then
Print("Echec de RegSetVar 5.")
endif
if Not(RegSetVariable(hkey3, "var_6", ccBuf, 46, REG_SZ)) then
Print("Echec de RegSetVar 5.")
endif
if Not(RegCloseKey(hkey3)) then
Print("Echec de RegCloseKey pour hkey3.")
endif
if Not(RegCloseKey(hkey2)) then
Print("Echec de RegCloseKey pour hkey2.")
endif
if Not(RegCloseKey(hkey1)) then
Print("Echec de RegCloseKey pour hkey1.")
endif
|
Copyright © 2014 CA Technologies.
Tous droits réservés.
|
|