(Applicable à Windows)
La fonction RegCreateKey crée une clé de registre spécifique. Si la clé existe déjà dans le registre, elle est ouverte.
Format de la fonction :
RegCreateKey(hKey as Integer, subkey as String) as Integer
Identifie une clé ouverte ou une clé prédéfinie. Le paramètre hKey peut être l'une des valeurs prédéfinies suivantes disponibles sur toutes les plates-formes Windows :
HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
Indique une chaîne qui donne le nom de la clé à ouvrir. Subkey doit être une sous-clé de la clé identifiée par hKey. Si le paramètre subkey est une chaîne vide, la fonction renvoie la même clé que celle spécifiée dans le paramètre hKey.
En cas de réussite, la fonction renvoie un descripteur vers la clé de registre qui vient d'être créée. 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, "Technologie CA")
if hkey2 = 0 then
Print("Echec de RegCreateKey 1.")
quitter
endif
if Not(RegSetValue(hkey1, "CA", "International")) 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.
|
|