This document is archived and information here might be outdated.  Recommended version.


ArcObjects runtime binding for VC++ developers (ArcObjects .NET 10.4 SDK)

ArcObjects runtime binding for VC++ developers


Summary
This topic discusses how to bind to an ArcObjects runtime for stand-alone Visual C++ applications.

Loading an ArcGIS runtime

Stand-alone ArcGIS applications must locate an appropriate ArcGIS product installation before any ArcObjects code (including license initialization) is called. You must decide what runtime is needed for the application. This must be done whether the license initialization is carried out using the LicenseControl or by using the AoInitialize class. The application programming interfaces (APIs) used to bind to the ArcGIS runtime are in IArcGISVersion in the ArcGISVersionLib namespace. To bind to the runtime, make a call to the LoadVersion method. See the following code example:
To bind to a runtime, import the ArcGISVerison library and use the VersionManager method on the IArcGISVersion interface.
[VCPP]
// Load the ArcGISVersion library.
// This code is commonly placed in the StdAfx.h header file.
#import "libid:6FCCEDE0-179D-4D12-B586-58C88D26CA78" raw_interfaces_only
  no_implementation

// The following code can be used to bind to ArcGIS Engine Runtime:
ArcGISVersionLib::IArcGISVersionPtr ipVer(__uuidof(ArcGISVersionLib
  ::VersionManager));
VARIANT_BOOL succeeded;
if (FAILED(ipVer->LoadVersion(ArcGISVersionLib::esriArcGISEngine, L "10.4",
  &succeeded)))
  return 0;
LoadVersion must be called after calling CoInitialize but before initializing a license.
IArcGISVersion contains the following methods, which can be used to find installed runtimes and the install locations of the runtimes:
  • GetActiveVersion—Returns the product code, version number, and path to the runtime.
  • GetVersions—Returns an enumeration of all the installed ArcGIS runtimes on the machine.
  • ProductNameFromCode—Returns a product name for the given product code.
  • LoadVersion—Binds to the specified ArcObjects runtime.