Adding a DWORD Value

Rdstne

Member
Joined
Oct 15, 2003
Messages
12
Hi there, just wondering if anyone can help me with how to add a DWORD value to the registry...I know how to add a regular string & value, just this ones got me puzzled...any help is greatly appreciated..,:)
Thanks.
 
Imports Microsoft.Win32

Dim reg As RegistryKey
reg = Registry.CurrentUser
reg.CreateSubKey("Software\My Test").SetValue("My Test", 1)
reg.Close()
 
I dont see why that is a dword value? it would seem you need to specify dword somewhere in the code.

What am i missing?
 
The .SetValue method appears to save as sz, multi_sz or expanded_sz when a string is passed, but in this case an integer is passed therefore is defaulted to DWORD. From the .NET Framework Class Library documentation:

Note When setting a value, the way in which the value being passed is stored in the registry is interpreted. There is no way to control whether the information being passed is stored as an sz, or an expanded_sz string, and therefore, all string values are interpreted as standard sz values.

I dont know why the documentation does not mention DWORD though.
HTH
 
Back
Top