I'm trying to get to HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\GameUX\, but the only subkey being returned in C# is MachineSettings - even though there are additional subkeys, including Games and several keys named for different user SIDs. How can I access these other keys? Even a standard user account can read the content of both Games and that account's own SID (when looking in regedit)...
Asked
Active
Viewed 2,418 times
1
-
What code are you using? And note that regedit runs as Administrator account (you should get a UAC prompt). – Dean Harding May 26 '10 at 00:54
-
Right - Running the app within visual C# express or as compiled and "as administrator" still brings about the same problem. The code is: http://pastebin.com/dEXa1EqD GameIDs[0], if it was reading the subkeys correctly, would equal Games, not MachineSettings (which is what it is currently). – CXL May 26 '10 at 01:18
-
Strange, this code works for me (both as admin and as a regular user). I'm on Win7 x64 with no uac... What version of .NET are you on? – Fredrik Johansson May 26 '10 at 09:42
-
I've discovered it's because I'm using C# Express, which only compiles 32-bit binaries. The GameUX key and subkeys I'm trying to access is in the 64-bit registry hive, which I can't see from a 32-bit application using the built in API for accessing the registry. – CXL May 27 '10 at 00:22
1 Answers
5
So the issue was related to running a 32-bit application in a 64-bit Windows environment. 64-bit Windows sandboxes 32-bit content (which is why there's a C:\Program Files (x86)) in a way that is transparent to applications. 32-bit applications that use the registry access a sandboxed hive inside HKLM\WOW6423Node, which is why I wasn't seeing the expected result when querying a key inside HKLM.
Fortunately, .NET 4.0 (introduced with VS.NET 2010 and its Express Edition counterparts) includes a super easy function that lets a 32-bit application see and use the 64-bit registry (and vice versa).
Answer is here: Create 64 bit registry key (non-WOW64) from a 32 bit application