How do you make a REG_DWORD?

  • Thread starter Thread starter Ty Moffett
  • Start date Start date
T

Ty Moffett

Dim rk As RegistryKey =
Registry.LocalMachine.CreateSubKey("Software\Microsoft\Windows\CurrentVersio
n\WindowsUpdate\Auto Update")

rk.SetValue("AUOptions", "4")



In the above example I am setting AUOptions to a value of 4. By default it
created a REG_SZ but I need it to be a REG_DWORD.



I can't for the life of me find anything written about this. Can anyone
offer some advice?
 
I found that if you do this

rk.SetValue("AUOptions", 4)

It automatically makes it a DWORD, but I don't really understand why.
 
Ty Moffett said:
Dim rk As RegistryKey =
Registry.LocalMachine.CreateSubKey("Software\Microsoft\Windows\CurrentVersio
n\WindowsUpdate\Auto Update")

rk.SetValue("AUOptions", "4")



In the above example I am setting AUOptions to a value of 4. By
default it created a REG_SZ but I need it to be a REG_DWORD.



I can't for the life of me find anything written about this. Can
anyone offer some advice?

You are passing a string. That's why a string is stored. Pass a numerical
value and a DWORD will be stored:


rk.SetValue("AUOptions", 4)
 
Ty Moffett said:
I found that if you do this

rk.SetValue("AUOptions", 4)

It automatically makes it a DWORD, but I don't really understand
why.

Because it's a numerical value, not a string.
 
Back
Top