0

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.


  • are you able to manually check / verify that ProgramName is in the registry..? perhaps you have a case sensitivity issue going on here.. have you tried changing the FirstOrDefault() to use First() Why use First instead of FirstOrDefault() - MethodMan
  • Registry redirection due to compiling for 32-bit on a 64-bit OS? Are you compiling as 32-bit? Does the key exist under Wow6432Node? - Blorgbeard
  • @Blorgbeard that was it. I didn't consider the 32/64-bit difference. Toss that in an answer and I'll mark it as correct. Thanks! - Russell Uhl
  • Great! I posted an answer. - Blorgbeard

1 답변


3

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.

Linked


Related

Latest