Reputation: 429
Im making a program that sees if a subkey in Registry exist and, if it doesnt exist it will create a subkey with a value (dword). This program is being create to replace a .bat file that people (non programmers) had to run to execute the .reg file in order to the things i listed above, witch isnt verry appealing for the user, thats why im making this program.
The .reg file sets the keys i want to set as dword, but the value has a 'c' in the end (this is what it looks like):
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU]
"ScheduledInstallTime"=dword:0000000c
and my c# code looks like this:
RegistryKey rk = Registry.LocalMachine.CreateSubKey(Globais.subkeyWU + @"\AU");
rk.SetValue("ScheduledInstallTime", 0000000c, RegistryValueKind.DWord);
The problem is that the .SetValue function doesnt accept the c in the end of the value, my guess is that it can only be numbers since its a dwrod (not sure), so, annyone knows how do i, bsaicly, do the same thing the .reg file is doing? maybe is hex values, something i dont know how to make in C#...
annyway, here is a printscreen on how it looks in the regedit (the .reg file does this):
Regardless, thanks!
Upvotes: 7
Views: 14832
Reputation: 11
Replace 0000000c by 12
rk.SetValue("ScheduledInstallTime", 12, RegistryValueKind.DWord);
Upvotes: 1
Reputation: 429
After reading the comments in my post, I can awnser my own question!
The solution to my problem is:
rk.SetValue("ScheduledInstallTime", 0x0000000c, RegistryValueKind.DWord);
or
rk.SetValue("ScheduledInstallTime", 12, RegistryValueKind.DWord);
Because im trying to store a hexadecimal value in the registry, i either translate it do decimal or type the full hexadecimal value, like i did above.
Thanks for the comments, really made me understand and solve my problem!
Upvotes: 9