After reading the documentation for microsoft.win32.registry.setvalue
consider the following -
Sub Main()
Try
Registry.CurrentUser.CreateSubKey("VBRegTest")
Registry.SetValue("HKEY_CURRENT_USER\VBRegTest", "String Value", "42")
Registry.SetValue("HKEY_CURRENT_USER\VBRegTest", "DWORD Value", 42)
'Following line unintentionally creates a string value because numeric value exceeds the capacity of 32 bit DWORD
Registry.SetValue("HKEY_CURRENT_USER\VBRegTest", "Unintended String Value", 3000000000)
'Following line creates a numeric 64 bit value
Registry.SetValue("HKEY_CURRENT_USER\VBRegTest", "QWORD Value", 3000000000, RegistryValueKind.QWord)
'Following line will throw an exception because the numeric value cannot fit into the explicitly specified DWORD data type
Registry.SetValue("HKEY_CURRENT_USER\VBRegTest", "QWORD Value", 3000000000, RegistryValueKind.DWord)
Catch ex As Exception
Console.WriteLine("Caught exception - {0}", ex.Message)
End Try
End Sub