I've checked some other replies on SO but as far I can see, this is a different issue than the hits I got.

When I open RegEdit, I can see a set of keys but when I list them from my program using e.g.:

Registry.LocalMachine.OpenSubKey(@"SOFTWARE").GetSubKeyNames()

some of them are missing. I thought it might to do with the access rights so I checked .CurrentUser too. The same behavior can be experienced there. A few of the subkeys are just not listed.

What am I missing?

有帮助吗?

解决方案

Is your OS x64? If that is the case, for "LocalMachine\Software" there are two different nodes: Normal for x64 apps and Wow6432Node for x86 apps.

A sample application to demonstrate the above.

using System;
using Microsoft.Win32;

namespace ConsoleApplication1
{
  internal class Program
  {
    public static void Main()
    {
      String[] values = Registry.LocalMachine.OpenSubKey(@"SOFTWARE").GetSubKeyNames();
      foreach (String value in values)
                Console.WriteLine(value);
    }
  }
}

This is the output of the code on my machine when the console application is built in x86:

Adobe
AGEIA Technologies
Alcohol Soft
Apple Computer, Inc.
Apple Inc.
Aureal
Avira
Azureus
BazisSoft
C07ft5Y
Canon
Citrix
...

This is the output on my machine when the console application is built in x64:

7-Zip
AGEIA Technologies
Apple Computer, Inc.
Apple Inc.
ATI Technologies
Canon
Classes
Clients
...

As you see, the outputs vary a lot based on whether the application is x86 or x64.

EDIT: A similar question was asked on StackOverflow previously.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top