Search code examples
.netvb.netregistry

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

Solution

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