How do you make a REG_DWORD?

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?
 
T

Ty Moffett

I found that if you do this

rk.SetValue("AUOptions", 4)

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

Armin Zingler

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)
 
A

Armin Zingler

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top