MTS MTS - 1 year ago 146 Question

Writing DWORD Value to Registry in VB.NET

I have this code and, essentially, I want to make it so the program writes a

value to the registry instead of an "SV" type.

This is my code:

My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\", True).SetValue("TestKey", "1")

Answer Source

See the MSDN docs about the method which shows that there is an additional parameter with the kind of value to write

So try this

My.Computer.Registry.LocalMachine.OpenSubKey("...", True).SetValue("TestKey", 1, RegistryValueKind.DWord)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download