Simple Registry Question

OSVBNET 1,391 Reputation points
2022-03-18T14:21:51.977+00:00

Hello

The different between these 2 and which one recommended to use?
Dim MyKey As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("xxx")
Dim MyKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("xxx", False)

and is this the safest and best method to convert to boolean when reading a DWORD?
blah = Convert.ToBoolean(MyKey.GetValue("Enabled"))

Thanks :)

Developer technologies VB
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 90,521 Reputation points
    2022-03-18T14:47:24.25+00:00

    You can use both as MS says : Reading from and Writing to the Registry Using the Microsoft.Win32 Namespace (Visual Basic)
    Microsoft.Win32.Registry is generally used for both C# & VB
    For booleans, you can see the answer in this thread : Boolean values and the registry
    (C# but same logic...)

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.