Reputation: 363
How can i write in registry DWORD hexadecimal value ? Instead of decimal value, like in this code example ?
RegistryKey key = Registry.LocalMachine;
key = klase.CreateSubKey(@"SYSTEM\CurrentControlSet\Control\Windows");
key.SetValue("CSDVersion2", "100", RegistryValueKind.DWord);
key.Close();
Solution is !
RegistryKey key = Registry.LocalMachine;
key = klase.CreateSubKey(@"SYSTEM\CurrentControlSet\Control\Windows");
key.SetValue("CSDVersion2", Convert.ToInt32("100", 16), RegistryValueKind.DWord);
key.Close();
Upvotes: 2
Views: 7238
Reputation: 141668
SetValue
takes an object, so you can give it a plain ol' integer. I would do something like this:
key.SetValue("CSDVersion2", 0x100, RegistryValueKind.DWord);
That sets CSDVersion2, to 0x100 hex, or 256 in decimal.
Upvotes: 3
Reputation: 62276
Using Convert.ToInt32(...) overload.
string strHexValue = Convert.ToInt32("100", 16).ToString();
where 16
is base.
Upvotes: 0