MTS MTS - 10 months ago 81 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")


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)