【问题标题】:How to check if the 64 bit version of flash player 10.2.161.23 is installed in the system or not IN C#?如何在 C# 中检查系统中是否安装了 64 位版本的 flash player 10.2.161.23?
【发布时间】:2011-02-24 08:54:01
【问题描述】:

我之前在以下链接中的stackoverflow中提出了这个问题-

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

但我的代码能够检测到 64 位版本 10.2.161.23,只有当系统上安装了其他 32 位版本 10.1.102.64 时。

但是当我卸载其他版本时 10.1.102.64,从系统,我的代码没有检测到64位版本 10.2.161.23,“type”变量的值为“null”。

我不知道为什么 64 位版本需要一个 32 位版本的闪存来检测 64 位版本的存在,使用上面的代码。

提前致谢。

【问题讨论】:

    标签: c# flash 64-bit


    【解决方案1】:

    一个很好的解决方案是这个函数是在一段时间前从另一个站点获取的:

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

    您可以尝试使用它来执行搜索,例如子键和更改:

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

    到这里:

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

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

    【讨论】:

    • 我可以知道语句 displayName = subkey.GetValue("DisplayName") as string; 中的字符串“DisplayName”是什么吗?表示.. PLz让我知道
    • 是注册表的一个子键,打开RegEdit就可以看到全部如代码中的声音一样...需要勾选的字段也是“DisplayVersion”,您可以将其作为搜索条件传递给搜索软件名称和他的版本...
    猜你喜欢
    • 1970-01-01
    • 2014-01-17
    • 2014-10-20
    • 1970-01-01
    • 2021-01-04
    • 2012-01-04
    • 2020-10-27
    • 1970-01-01
    • 2011-06-24
    相关资源
    最近更新 更多