codeLover
codeLover

Reputation: 3810

How to check if the 64 bit version of flash player 10.2.161.23 is installed in the system or not IN C#?

I had earlier asked the question in stackoverflow in the followin link-

How to check if a particular version of flash player is installed or not in C#.?

Type type = Type.GetTypeFromProgID("ShockwaveFlash.ShockwaveFlash");
object flashObject = Activator.CreateInstance(type);

    object versionString = flashObject.GetType().InvokeMember("GetVariable", BindingFlags.InvokeMethod,null, flashObject, new object[] {"$version"}); 

But my code is able to detect the 64 bit version 10.2.161.23, only when, the other 32 bit version 10.1.102.64 is installed on the system.

But when I uninstall the other version 10.1.102.64, from the system, my code is not detecting the 64 bit version 10.2.161.23 and the value of "type" varable is "null".

I dont know why that the 64 bit version needs a 32 bit version flash to be present for detecting the presence of 64 bit version, using the above code.

Thanks In Advance.

Upvotes: 1

Views: 1006

Answers (1)

Achilleterzo
Achilleterzo

Reputation: 742

A good solution is this function taken time ago from another site:

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

        // search in: CurrentUser
        key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
        if (key != null) 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");
        if (key != null) 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");
        if (key != null) 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;
    }

You can try to play with it to perform your search, like subkeys and changing this:

if (p_name.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true)

To this:

if (displayName.Contains(p_name) == true) //"Flash Player" is your case... (untested) 

Source: http://mdb-blog.blogspot.com/2010/09/c-check-if-programapplication-is.html

Upvotes: 1

Related Questions