获取系统中安装的应用程序应用程序、系统

由网友(回憶總是虐心菂ノ)分享简介:如何使用C#code得到系统中安装的应用程序?How to get the applications installed in the system using c# code?推荐答案迭代通过注册表项SOFTWARE \微软\的Windows \ CurrentVersion \卸载似乎给了一个COM preh...

如何使用C#code得到系统中安装的应用程序?

How to get the applications installed in the system using c# code?

推荐答案

迭代通过注册表项SOFTWARE 微软的Windows CurrentVersion 卸载似乎给了一个COM prehensive安装的应用程序列表。

Iterating through the registry key "SOFTWAREMicrosoftWindowsCurrentVersionUninstall" seems to give a comprehensive list of installed applications.

除了下面的例子中,你可以找到使用LINQ here一个类似的版本我做了什么here.

Aside from the example below, you can find a version using Linq here and a similar version to what I've done here.

这是一个粗略的例子,你会probaby想要做的东西去掉空白的行状中提供的第二个环节。

This is a rough example, you'll probaby want to do something to strip out blank rows like in the 2nd link provided.

string registry_key = @"SOFTWAREMicrosoftWindowsCurrentVersionUninstall";
using(Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
{
    foreach(string subkey_name in key.GetSubKeyNames())
    {
        using(RegistryKey subkey = key.OpenSubKey(subkey_name))
        {
            Console.WriteLine(subkey.GetValue("DisplayName"));
        }
    }
}

另外,您也可以使用WMI作为已经提到:

Alternatively, you can use WMI as has been mentioned:

ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_Product");
foreach(ManagementObject mo in mos.Get())
{
    Console.WriteLine(mo["Name"]);
}

但是,这是相当慢的执行,我听说它可能只在ALLUSERS已安装列表中的程序,尽管这可能是不正确的。它也忽略了Windows组件和放大器;更新,这可能是方便你。

But this is rather slower to execute, and I've heard it may only list programs installed under "ALLUSERS", though that may be incorrect. It also ignores the Windows components & updates, which may be handy for you.

阅读全文

相关推荐

最新文章