Writing HEX value to Binary registry key

  • Thread starter Thread starter Steve Bostedor
  • Start date Start date
S

Steve Bostedor

I'm trying to use the RegistryKey to write a hex number into the registry as
a binary type.

I know see that in DotNet, the RegistryKey tries to interprate what registry
type to create depending on the type of structure the variable was dimmed
as. I dimmed it as a character array, then dumped each value into that
character array, then wrote it to the registry and sure enough, it created a
binary entry of it .... but ....

The problem is that it wrote it to the registry as a bunch of numbers and
not as the HEX that I wanted. When I open up the registry, I want to see
hex numbers like: A3 FF 35 B3 56 and not: 33 55 123 54 56 22.

Does anyone know how to make the hex numbers show up in a binary key using
the RegistryKey?
 
Hi Steve!

you need to pass a byte array. you can use the System.BitConverter() class
to convert your value :
'***
Dim rk As RegistryKey = Registry.CurrentUser
rk = rk.CreateSubKey("Test")
rk.SetValue("binary", BitConverter.GetBytes(&HAAFF))
'***
 
Back
Top