Kai
Kai

Reputation: 983

How to detect whether a particular software is installed in windows?

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

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)

Upvotes: 3

Views: 794

Answers (3)

Kai
Kai

Reputation: 983

Thanks everyone. But i used this program in C#. I created this class library ,loaded the dll in the webpage and use the IsApplicationInstalled method.

public static bool IsApplicationInstalled(string p_name)
{
string displayName;
RegistryKey key;

// search in: CurrentUser
key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
foreach (String keyName in key.GetSubKeyNames())
{
    RegistryKey subkey = key.OpenSubKey(keyName);
    displayName = subkey.GetValue("DisplayName") as string;
    if (p_name.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true)
    {
        return true;
    }
}

// search in: LocalMachine_32
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
foreach (String keyName in key.GetSubKeyNames())
{
    RegistryKey subkey = key.OpenSubKey(keyName);
    displayName = subkey.GetValue("DisplayName") as string;
    if (p_name.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true)
    {
        return true;
    }
}

// search in: LocalMachine_64
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall");
foreach (String keyName in key.GetSubKeyNames())
{
    RegistryKey subkey = key.OpenSubKey(keyName);
    displayName = subkey.GetValue("DisplayName") as string;
    if (p_name.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true)
    {
        return true;
    }
}
// NOT FOUND
return false;

}

Upvotes: 0

Naresh
Naresh

Reputation: 2673

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

Upvotes: 2

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174329

You can't really detect this as you have no access to the system. Your web app should simply try to create an instance of that ActiveX and display a message to the user if that fails.

Upvotes: 4

Related Questions