At http://tinyurl.com/lkxz there is an example of how to read Registry
values of #REG_SZ and #REG_DWORD type, but not #REG_BINARY.
Does anyone know how to read #REG_BINARY values? Thanks.
Reading #REG_BINARY Registry entries?
Just like when you read a string value. (provide a buffer for the data and
it's size, and RegQueryValueEx_() will fill the buffer.
Example:
In the code you mentioned, line 70:
This call receives the type of data in 'lType' and it's size in 'cch'.
Now when 'lType' is #REG_BINARY, you need to allocate memory
of size 'cch'.
Now the actual call to get the value can look like this:
Assuming you used AllocateMemory() to allocate the memory.
Here's a piece of code that fits in the Select/EndSelect of the
QueryValueEx() procedure in the code you mentioned:
Timo
it's size, and RegQueryValueEx_() will fill the buffer.
Example:
In the code you mentioned, line 70:
This call receives the type of data in 'lType' and it's size in 'cch'.
Now when 'lType' is #REG_BINARY, you need to allocate memory
of size 'cch'.
Now the actual call to get the value can look like this:
Code: Select all
lrc = RegQueryValueEx_(lhkey, szValueName, 0, @lType, MemoryID(), @cch)
Here's a piece of code that fits in the Select/EndSelect of the
QueryValueEx() procedure in the code you mentioned:
Code: Select all
;For Binary
Case #REG_BINARY
If AllocateMemory(0, cch)
lrc = RegQueryValueEx_(lhkey, szValueName, 0, @lType, MemoryID(), @cch)
If lrc = #ERROR_NONE
;
; Binary Data is now in the allocated buffer, do whatever you want with it.
;
EndIf
Else
; allocation error
lrc = -1
EndIf
quidquid Latine dictum sit altum videtur
Thanks Freak, I got what I wanted by modifying your procedure like so:
Code: Select all
Case #REG_BINARY
If AllocateMemory(0, cch)
lrc = RegQueryValueEx_(lhkey, szValueName, 0, @lType, MemoryID(), @cch)
If lrc = #ERROR_NONE
;
; Binary Data is now in the allocated buffer, do whatever you want with it.
TStr1.s = ""
TStr2.s = ""
For i = 0 To cch-1
TStr1 = Hex(PeekB(MemoryID()+i))
If Len(TStr1) = 1 : TStr1 = "0" + TStr1 : EndIf
TStr2 +TStr1+" "
Next
Debug TStr2
;
EndIf
Else
; allocation error
lrc = -1
EndIf
@wolf
Code: Select all
DataSection
regbin_data:
Data.b 0,1,2,3,4,5,6,7,8,9,128,255 ;byte in decimal !
end_regbin_data:
EndDataSection
openkey = #HKEY_LOCAL_MACHINE
subkey.s = "SOFTWARE"
keyset.s = "test"
hkey.l = 0
RegCreateKey_(OpenKey,SubKey,@hKey)
RegSetValueEx_(hKey,keyset,0,#REG_BINARY,?regbin_data,?end_regbin_data - ?regbin_data)
RegCloseKey_(hKey)
["1:0>1"]