Read registry key

前端 未结 2 389
没有蜡笔的小新
没有蜡笔的小新 2021-01-29 04:40

Am I doing something wrong? I get no value back...

Imports Microsoft.Win32
...
Dim s As String = \"\"
Dim reg As RegistryKey

reg =Registry.LocalMachine.OpenSubK         


        
相关标签:
2条回答
  • 2021-01-29 05:16

    Try messagebox.show(s.ToString)

    Wehn you compile to 32 bit on a 64 bit OS, when the key will be created in the HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ node. However, the app that creates it should be able to read it back, even if you can't find it where you expected to in RegEdit.exe

    0 讨论(0)
  • 2021-01-29 05:17

    If you get no exception then you can safely assume that the value does not exist or has an empty string as its value.

    If you are sure that the value in fact exists then the next explanation is that your machine runs a 64-bit operating system. Where the registry is virtualized for 32-bit processes. They will read values from HKLM\Software\Wow6432Node. And that you're running VS2010, it forces projects to run in 32-bit by default. Project + Properties, Compile tab, scroll down, Advanced Compile Options. Change Target CPU to AnyCPU. Not available in the Express edition afaik, you'd have to edit the .vbproj file by hand.

    0 讨论(0)
提交回复
热议问题