7

Can anyone tell me why I can't access the registry key of "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData"?

if I query the GetSubKeysNames of "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer" it only returns one value being "Secure" ----> Where are all the other subkeys?

Thanks.

gleng
  • 6,185
  • 4
  • 21
  • 35
Tim Windsor
  • 319
  • 1
  • 5
  • 17
  • 1
    Please post a few lines of code. How do you construct your RegistryKey instance? – helb Nov 04 '13 at 13:51
  • 1
    The real question is "Why are you trying to access the registry key `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData`?" That information is internal OS data. – Raymond Chen Nov 04 '13 at 14:04
  • @Raymond Chen: One possibility is a crashed install or a failed hard drive where a bunch of ...\installer\Folders were left around with 8dot3 references(1061 of them) that won't let one get rid of 8dot3. – user3461121 Oct 30 '19 at 02:00

1 Answers1

17

High odds that you are running your program on the 64-bit version of Windows and it is forced to run in 32-bit mode. The registry redirector will make you actually read the keys in HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node. And yes, that one also has a Microsoft\Windows\CurrentVersion\Installer key but it is pretty empty. Use Regedit.exe to compare.

The simplest fix is to remove the forcing. Project + Properties, Build tab, set the Target platform setting to AnyCPU. If you have VS2012 and up then untick the "Prefer 32-bit" option. Repeat for the Release configuration. If you must run in 32-bit mode then you can use the .NET 4+ RegistryKey.OpenBaseKey() method, passing RegistryView.Registry64.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536