I have an old VS project that was using ArcGis for a map control. I now have 10.2 on my machine. code that I used previously to find & initialize the license no longer works. I know the enums changed I fixed that. But still returns an enumstatus of EsriLicenseNotLicensed. I did find that in 10.xx one should call

if (ESRI.RuntimeManager.ActiveRuntime == null)

But that is for .NET what do I do for C++? In my code I call

esriLicenseStatus enumStatus = esriLicenseNotLicensed;
IAoInitializePtr pLicense ( __uuidof (AoInitialize));
esriLicenseProductCode eProdCode = esriLicenseProductCodeEngine;

        while( enumStatus != esriLicenseAvailable )
            pLicense->IsProductCodeAvailable ( eProdCode, &enumStatus );

            if ( enumStatus != esriLicenseAvailable )
                if (eProdCode == esriLicenseProductCodeEngine)
                    eProdCode = esriLicenseProductCodeEngineGeoDB;
                else if (eProdCode == esriLicenseProductCodeEngineGeoDB)
                    eProdCode = esriLicenseProductCodeArcServer;
                else if (eProdCode == esriLicenseProductCodeArcServer)
                    eProdCode = esriLicenseProductCodeBasic;
                else if (eProdCode == esriLicenseProductCodeBasic)
                    eProdCode = esriLicenseProductCodeStandard;
                else if (eProdCode == esriLicenseProductCodeStandard)
                    eProdCode = esriLicenseProductCodeAdvanced;

later I call

pLicense->Initialize ( eProdCode, &enumStatus );

which also fails with an enumStatus of no license

1 Answer 1


I got it working. I had to add in the stafx.h file:

/* Engine Version support */
#import "libid:6FCCEDE0-179D-4D12-B586-58C88D26CA78" no_namespace raw_interfaces_only no_implementation rename("esriProductCode", "esriVersionProductCode")
#define ESRI_SET_VERSION(prod) \
  HRESULT hr; \
  IArcGISVersionPtr ipVersion(__uuidof(VersionManager)); \
  if(!SUCCEEDED(hr = ipVersion->LoadVersion(prod, L"", &vb))) \
    fprintf(stderr, "LoadVersion() failed with code 0x%.8x\n", hr); \
    else if(vb != VARIANT_TRUE) \
    fprintf(stderr, "LoadVersion() failed\n"); \

Then in the file before I attempted to check out the license I had to add:


I got this from looking at some C++ samples on ESRI's site, in particular the sample for "Converting a tin to a point shapefile" at http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/Converting_a_tin_to_a_point_shapefile/000100000nqq000000/

  • You can accept your own answer with the checkbox
    – BERA
    Apr 27, 2018 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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