如何检查特定版本的Flash播放器是否安装在C#中。 [英] How to check if a particular version of flash player is installed or not in C#.?

查看:169
本文介绍了如何检查特定版本的Flash播放器是否安装在C#中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的代码检查是否安装了特定版本的Flash播放器。
我使用了下面的代码:

 使用Microsoft.Win32 

RegistryKey RK = Registry。 CurrentUser.OpenSubKey( HKEY_LOCAL_MACHINE\\SOFTWARE\\Macromedia\\FlashPlayer);

if(RK!= null)
{
//这是
}
else
{
//是不存在
}

在注册表中如果我搜索版本为10.2.161.23的Flash Player,位置


HKEY_LOCAL_MACHINE \SOFTWARE\Macromedia

有2个文件夹:


  1. FlashPlayer和

  2. FlashPlayerActiveX。 li>

但是,我上面的代码不工作。

检查系统中是否安装了特定版本的Flash播放器使用C#.NET 解决方案

如果Adobe可以实例化对象ShockwaveFlash.ShockwaveFlash< major version>,那么Adobe的旧版(前10)IE Flash检测代码将用于在VBScript中进行测试。如果它只是你想测试的主要版本,你可以检查HKCR下的那些密钥,例如 HKEY_CLASSES_ROOT \ShockwaveFlash.ShockwaveFlash.10


$ b SWFObject 实例化无版本的对象名称ShockwaveFlash.ShockwaveFlash,并查询它的 $ version 属性。在C#中这样做:

  //从注册表中查找flash对象类型
var type = Type.GetTypeFromProgID ShockwaveFlash.ShockwaveFlash);
if(type == null)
{
//不闪烁
return;
}

//创建一个flash对象来查询
//(应该可以尝试/抓住CreateInstance)
var flashObject = Activator.CreateInstance(type);
var versionString = flashObject.GetType()
.InvokeMember(GetVariable,BindingFlags.InvokeMethod,
null,flashObject,new object [] {$ version})
作为字符串;
//例如WIN 10,2,15,2,26

//清理分配的COM对象
Marshal.ReleaseComObject(flashObject);


I want to check from my code if a particular version of flash player is installed or not. I used the following code

using Microsoft.Win32

RegistryKey RK = Registry.CurrentUser.OpenSubKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\Macromedia\\FlashPlayer");

if (RK != null)
{
    // It's there 
}
else
{
    // It's not there 
} 

In registry If I search for flash player with version 10.2.161.23, the location

"HKEY_LOCAL_MACHINE\SOFTWARE\Macromedia"

is having 2 folders:

  1. FlashPlayer and
  2. FlashPlayerActiveX.

But, my above code is not working.

Kindly let me know how to check if a particular version of flash player is installed in a system or not USING C#.NET.

解决方案

Adobe's old (pre 10) IE Flash detection code used to test in VBScript if it could instantiate object ShockwaveFlash.ShockwaveFlash.<major version>. If it's just the major version you want to test, you can check for those keys under HKCR, e.g. HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash.10.

SWFObject instantiates the version-less object name, ShockwaveFlash.ShockwaveFlash, and queries its $version property. To do this in C#:

// Look up flash object type from registry
var type = Type.GetTypeFromProgID("ShockwaveFlash.ShockwaveFlash");
if (type == null)
{
  // No flash
  return;
}

// Create a flash object to query
// (should probably try/catch around CreateInstance)
var flashObject = Activator.CreateInstance(type);
var versionString = flashObject.GetType()
                      .InvokeMember("GetVariable", BindingFlags.InvokeMethod,
                                    null, flashObject, new object[] {"$version"})
                    as string;
// e.g. "WIN 10,2,152,26"

// Clean up allocated COM Object
Marshal.ReleaseComObject(flashObject);

这篇关于如何检查特定版本的Flash播放器是否安装在C#中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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