获取系统中安装的应用程序 [英] Get installed applications in a system

查看:175
本文介绍了获取系统中安装的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

推荐答案

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

Iterating through the registry key "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" seems to give a comprehensive list of installed applications.

除了下面的例子中,你可以找到使用LINQ <一个版本href="http://www.debugrelease.com/2008/08/29/get-a-list-of-installed-applications-using-linq-and-c/">here一个类似的版本我做了什么<一href="http://bytes.com/groups/net-c/276143-getting-list-installed-programs-windows-using-c">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 = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
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.

这篇关于获取系统中安装的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆