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;
}
}
No comments:
Post a Comment