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

前端 未结 1 2038
独厮守ぢ
独厮守ぢ 2021-01-06 12:03

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 = R         


        
相关标签:
1条回答
  • 2021-01-06 12:51

    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);
    
    0 讨论(0)
提交回复
热议问题