如何在 Windows 7 64 位上使用 C# 从注册表获取所有启动进程的列表?

发布于 2024-10-08 07:03:44 字数 1108 浏览 0 评论 0原文

大家好,我有一个奇怪的问题。

我试图从注册表中获取所有启动程序的列表 - LocalMachine、CurrentUser、子项 Run、RunOnce、RunOnceEx。之后我可以在 Startup 文件夹中获取链接列表

For Win64 我发现启动程序在这个键中

LocalMachine/Software/Wow6432Node/Microsoft/Windows/CurrentVersion/Run

问题出在这段代码中,运行它我得到不同子项中的应用程序列表 LocalMachine\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Run 而不是下面描述的 LocalMachine\Software\Microsoft\Windows\CurrentVersion\Run

这正常吗?

 Microsoft.Win32.RegistryKey key;
 key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", false);

 foreach (string appName in key.GetValueNames()) 
 {
      try
      {
         MessageBox.Show(appName);
      }
      catch (Exception ex) 
      {
                
      }
      
 }

我尝试使用此 WMI 解决方案,但它没有获取所有启动应用程序。这就是为什么我决定从注册表手动获取它们。

  1. 这个脚本正确吗?为什么它没有做它应该做的事情?

  2. 还有其他方法获取所有启动应用程序和进程吗?

    谢谢

Hi guys I have a strange issue.

I am trying to get list of all startup programs from Registry - LocalMachine,CurrentUser, subkeys Run, RunOnce, RunOnceEx. And after that I can get list of links in Startup folder

For Win64 I found that startup programs are in this key

LocalMachine/Software/Wow6432Node/Microsoft/Windows/CurrentVersion/Run

The problem is in this code, running it I get List of apps which are in different Subkey LocalMachine\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Run instead of the described bellow LocalMachine\Software\Microsoft\Windows\CurrentVersion\Run

Is that normal?

 Microsoft.Win32.RegistryKey key;
 key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", false);

 foreach (string appName in key.GetValueNames()) 
 {
      try
      {
         MessageBox.Show(appName);
      }
      catch (Exception ex) 
      {
                
      }
      
 }

I tryed using this WMI solution but it didnt get all startup apps. That's why i decided to get them manually from the Registry.

  1. Is this script correct and why it doesn't do what it is supposed to do?

  2. Is there any other way to get all startup apps and processes?

    Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

久伴你 2024-10-15 07:03:44

在 64 位 Windows 操作系统上,有 2 个不同的 HKLM\Software 配置单元。一种用于 64 位应用程序(即 HKLM\Software),另一种用于 32 位应用程序(从 64 位应用程序查看时为 HKLM\Software\Wow6432Node。对于 32 位应用程序,它被视为 HKLM\Software )。

如果将 .Net 应用程序编译为 MSIL 或 x64,则可以通过将 Wow6432node 添加到注册表路径来访问 32 位软件配置单元。

否则,您也可以编译为 x86 并以 32 位运行。

希望这有帮助

On a 64-bits windows OS, there are 2 distinct HKLM\Software hives. One for 64-bits apps (which is HKLM\Software) and one for 32-bits apps (which is HKLM\Software\Wow6432Node when viewed from a 64-bits apps. It is viewed as HKLM\Software for a 32-bits apps).

If you compile your .Net application as MSIL or x64, you could access the 32-bit software hive by adding Wow6432node to the registry path.

Otherwise, you could also compile as x86 and run in 32-bits.

Hope this help

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文