如何检测Windows中是否安装了特定软件? [英] How to detect whether a particular software is installed in windows?

查看:279
本文介绍了如何检测Windows中是否安装了特定软件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是编程新手。我已经获得了一个虚拟会议站点。现在我需要修改站点。

I am new to programming. I've been given a virtual conferencing site. Now i need to modify the site.

当用户登录到会议站点时,它必须检测其系统中是否安装了特定软件(该软件是用于进行视频通话(它使用ActiveX对象)。

While the user logins into the conferencing site,it must detect whether his system has a particular software installed in his system(that software is used for making video calls.It uses ActiveX objects).

哪种方法是检测系统中已安装软件的最佳方法? (坦白地说,我什至不知道哪种语言最能达到目的)

Which is the best method to detect the presence of the installed software in the system? (Frankly speaking i don't even know which language best serves the purpose)

推荐答案

    public static bool IsApplictionInstalled(string p_name)
{
    string keyName;

    // search in: CurrentUser
    keyName = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
    if (ExistsInSubKey(Registry.CurrentUser, keyName, "DisplayName", p_name) == true)
    {
        return true;
    }

    // search in: LocalMachine_32
    keyName = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
    if (ExistsInSubKey(Registry.LocalMachine, keyName, "DisplayName", p_name) == true)
    {
        return true;
    }

    // search in: LocalMachine_64
    keyName = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
    if (ExistsInSubKey(Registry.LocalMachine, keyName, "DisplayName", p_name) == true)
    {
        return true;
    }

    return false;
}

private static bool ExistsInSubKey(RegistryKey p_root, string p_subKeyName, string p_attributeName, string p_name)
{
    RegistryKey subkey;
    string displayName;

    using (RegistryKey key = p_root.OpenSubKey(p_subKeyName))
    {
        if (key != null)
        {
            foreach (string kn in key.GetSubKeyNames())
            {
                using (subkey = key.OpenSubKey(kn))
                {
                    displayName = subkey.GetValue(p_attributeName) as string;
                    if (p_name.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true)
                    {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}

这篇关于如何检测Windows中是否安装了特定软件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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