i ve been searching for a function to set a registry key with c#.
Obvously there is the method Registry.SetValue(KEY, valueName, value, registryValueKind)
[... whereby valueName is the name of the edited value, KEY is the main key name and registryValueKind is the type of change to be made]
If you have a closer look at registryValueKind-Enum there are 8 types:
In a Msdn-Article the different data-types are described:
So i wonder how to store a hex(7)-value [therefore a REG_HEX-value] with the help of Registry.SetValue().
Further i wonder how to save a value like hex(7):56,00,45,00,4e,00,30,00,00,00,4c,00,4f,00,4f,00,50,00,42,\ 00,41,00,43,00,4b,00,00,00,00,00 which is, in addition to being of type hex(7) seperated by a "\".
Thanks in adavance!
There is no such thing as "hexadecimal value", hexadecimal is just a textual representation of a binary value.
What you want is:
Registry.SetValue(
"HKEY_CURRENT_USER\\MyKeyName",
"MyValue",
new byte[] { 0x56, 0x00, 0x45, 0x00, 0x4e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x4f, 0x00, 0x4f, 0x00, 0x50, 0x00, 0x42, 0x00, 0x41, 0x00, 0x43, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x00 },
RegistryValueKind.Binary);