2

我已经检查了关于 SO 的其他一些回复,但据我所知,这与我得到的点击量不同。

当我打开 RegEdit 时,我可以看到一组键,但是当我使用例如从程序中列出它们时:

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

其中一些失踪了。我认为这可能与访问权限有关,所以我也检查.CurrentUser了。在那里可以体验到相同的行为。只是没有列出一些子项。

我错过了什么?

4

1 回答 1

3

你的操作系统是 x64 的吗?如果是这种情况,对于“LocalMachine\Software”有两个不同的节点:x64 应用程序的正常和 x86 应用程序的 Wow6432Node。

演示上述内容的示例应用程序。

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);
    }
  }
}

这是在 x86 中构建控制台应用程序时我机器上的代码输出:

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

这是在 x64 中构建控制台应用程序时我机器上的输出:

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

如您所见,根据应用程序是 x86 还是 x64,输出会有很大差异。

编辑:之前在 StackOverflow 上提出了类似的问题。

于 2012-11-10T18:55:04.353 回答