Comment écrire une valeur binaire dans le registre

Auteur : Ramses

Voici commment écrire une donnée en mode binaire dans le registre.


// Vars
hKey is int
lpcbData is int
ulOptions is int
ulOptions1 is int
ulOptions2 is int
lsData is string

// Read option
ulOptions1=BinaryOR(0x00020000, 0x0001)
ulOptions1=BinaryOR(ulOptions1, 0x0008)
ulOptions1=BinaryOR(ulOptions1, 0x0010)
ulOptions1=BinaryAND(ulOptions1, BinaryNOT(0x00100000))

// Write option
ulOptions2=BinaryOR(0x00020000, 0x0002)
ulOptions2=BinaryOR(ulOptions2, 0x0004)
ulOptions2=BinaryAND(ulOptions2, BinaryNOT(0x00100000))

// Open key ( 0x80000001 --> HKEY_CURRENT_USER\ )
// With subkey Software\MyOtherSubKey
IF API("ADVAPI32.DLL","RegOpenKeyExA", 0x80000001, "Software\MyOtherSubKey", 0, OUBinaire(ulOptions1, ulOptions2), &hKey)<>0 THEN
	Error(ErrorInfo())
	RETURN
END

// What we want to store
lsData="Bonjour,"+RC+RC+"My Name Is Bond, James Bond"

// Set binary data
IF API("ADVAPI32.DLL","RegSetValueExA", hKey, "MyValueName", Null, "binary", lsData, Taille(lsData))<>0 THEN
	API("ADVAPI32.DLL","RegCloseKey",hKey)
	Error(ErrorInfo())
	RETURN
END

// Close opened key
API("ADVAPI32.DLL","RegCloseKey",hKey)