MTS MTS - 3 months ago 33
Vb.net 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

DWORD
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

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)