Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am building an ArcGIS 10 Addin that dumps out as much debug information about a system that I can get. I am currently trying to query which extensions are active in the ArcMap session. The following code is to query on the active ESRI extensions, but does not show the 3rd party extensions. Any ideas of what I need to do to get the information on 3rd party extensions?

public string Extensions
{
   get 
   {
      var aoi = new ESRI.ArcGIS.esriSystem.AoInitializeClass();
      var extensionsEnum = aoi.GetProductExtensions(esriLicenseProductCode.esriLicenseProductCodeArcInfo);
      var licenseCode = extensionsEnum.Next();
      var ret = "";
      while(Convert.ToInt32(licenseCode) != -1)
      {
         if(aoi.IsExtensionCheckedOut(licenseCode))
            ret += aoi.GetLicenseExtensionName(licenseCode) + ",";
         licenseCode = extensionsEnum.Next();
      }
      return ret+Environment.NewLine;
  }
}

Here is the working code:

public string Extensions
{
   get
   {
      var extensionManager = (IExtensionManager) ArcMap.Application;

      var ret = "";
      for (int i = 0; i < extensionManager.ExtensionCount; i++)
      {
          var extension = extensionManager.Extension[i];
          var config = extension as IExtensionConfig;
          if(config == null || config.State == esriExtensionState.esriESEnabled)
              ret += extension.Name + ",";
      }

      var jitExtensionManager = (IJITExtensionManager) ArcMap.Application;
      for (int i = 0; i < jitExtensionManager.JITExtensionCount; i++ )
      {
         var extensionUid = jitExtensionManager.JITExtensionCLSID[i];
         if(jitExtensionManager.IsLoaded(extensionUid))
         {
            var extension = ArcMap.Application.FindExtensionByCLSID(extensionUid);    
            var config = extension as IExtensionConfig;
            if (config == null || config.State == esriExtensionState.esriESEnabled)
               ret += extension.Name + ",";
          }
       }

       ret = ret.Substring(0, ret.Length - 1);
       return ret+Environment.NewLine;
    }
 }
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Yes. Use the ExtensionManager class.

share|improve this answer
    
Awesome, just what I was looking for! Thanks. –  baens Feb 28 '12 at 18:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.