Thursday, 26 April 2018

arcobjects - How can you find ArcGIS version programatically?


Is there a way using ArcObjects.net to find out what version of ArcGIS is installed on a machine (i.e. 9.3., 10.0, 10.1)?



Answer



In ArcObjects .NET, use the RuntimeManager e.g.:


Listing all installed runtimes:


var runtimes = RuntimeManager.InstalledRuntimes;
foreach (RuntimeInfo runtime in runtimes)
{

System.Diagnostics.Debug.Print(runtime.Path);
System.Diagnostics.Debug.Print(runtime.Version);
System.Diagnostics.Debug.Print(runtime.Product.ToString());
}

or, to just get the currently active runtime:


bool succeeded = ESRI.ArcGIS.RuntimeManager.Bind(ProductCode.EngineOrDesktop);
if (succeeded)
{
RuntimeInfo activeRunTimeInfo = RuntimeManager.ActiveRuntime;

System.Diagnostics.Debug.Print(activeRunTimeInfo.Product.ToString());
}

Also in arcpy, you can use GetInstallInfo.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...