Rubrique précédente: Fonctions de manipulation du registreRubrique suivante: RegCreateKey : Créer une clé de registre


RegCloseKey – Fermer la clé de registre

(Applicable à Windows)

La fonction RegCloseKey ferme la clé de registre associée au paramètre hKey, un descripteur obtenu à partir d'un appel de RegOpenKey ou de RegCreateKey.

Format de la fonction :

RegCloseKey(hKey as Integer) as Boolean
hkey

Valeur hKey de la clé du registre.

Une fois qu'elle a réussi, la fonction renvoie la valeur True. Si la fonction échoue (hKey n'est pas le descripteur d'une clé de Registre ouverte et valide), la fonction renvoie la valeur False.

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