Russell Uhl
Russell Uhl

Reputation: 4531

C# registry key not in list

I have the following code:

RegistryKey SOFTWARE = Registry.LocalMachine.OpenSubKey((
    from x in Registry.LocalMachine.GetSubKeyNames()
    where x == "SOFTWARE"
    select x).FirstOrDefault());
RegistryKey Allworx = SOFTWARE.OpenSubKey((
    from x in SOFTWARE.GetSubKeyNames()
    where x == "ProgramName"
    select x).FirstOrDefault());

This compiles and runs and all that, the issue is that "ProgramName" is not in the list of SOFTWARE's subkeys. I know it exist because I am currently looking at it in regedit. I have granted myself full control of the entire SOFTWARE key, as well as the ProgramName key.

For reference, both the code and regedit agree that I am looking in

Computer
  L--HKEY_LOCAL_MACHINE
       L--SOFTWARE

In addition to this issue, SOFTWARE.getSubKeyNames() is also returning a bunch of names that do NOT appear in regedit. No idea where these are coming from, and in general, I'm more concerned about why my program name is not showing up like it should be.

Upvotes: 1

Views: 1023

Answers (1)

Blorgbeard
Blorgbeard

Reputation: 103467

You're running into registry redirection. 64-bit Windows silently redirects certain registry requests from 32-bit programs.

You can either compile as a 64-bit program, or ask for the 64-bit view when you open the key.

Upvotes: 4

Related Questions