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.
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.
ProgramName
is in the registry..? perhaps you have a case sensitivity issue going on here.. have you tried changing theFirstOrDefault()
to useFirst()
Why use First instead of FirstOrDefault() - MethodMan