SajjadZare
SajjadZare

Reputation: 2378

Null in get value from registry

I want to get value from registry, but value is null

I check key in registry and exist in specific path with value

RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\MICROSOFT\\WINDOWS");
string st = key.GetValue("LastVerify").ToString();

I asked this question before and mark it as duplicate, I find several question about this and I use answers but again have problem.

question 1

question 2

screnshot of registry: enter image description here

Upvotes: 1

Views: 604

Answers (1)

Kamil Budziewski
Kamil Budziewski

Reputation: 23087

You need to change your target machine to x64, because you can't read this values using x86.

using (var key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\MICROSOFT\\WINDOWS"))
{
      var value = key.GetValueNames();
}

this code works fine under x64.

Here you can find more about accessing registry in x64 and x86 view: https://msdn.microsoft.com/en-us/library/aa384129.aspx

By default, a 32-bit application running on WOW64 accesses the 32-bit registry view and a 64-bit application accesses the 64-bit registry view.

If you look at process manager, regedit.exe start in 64-bit mode, so it opens different view than your application was using.

Upvotes: 1

Related Questions