Create new instance of the MapObjects MapControl without the MO license using CoCreate

Last Published: April 25, 2020


** Internal Publish Only! This article may contain information that is not intended for external circulation. **

Instructions below contain a C++ code sample that shows how to programmatically create a new instance of the MapControl without the MO license using CoCreate.


  1. Add the following code to stdafx.h. Note: the double quotes are included.

    #import "c:\program files\common files\esri\mo2x.ocx" raw_interfaces_only no_implementation no_namespace

  2. The code snippet below shows how to create the new instance of the MapControl.


    void COcxcreateDlg::OnButton1()
    // Standard IClassFactory2 interface. Used to create instances
    // of objects which are licensed.
    IClassFactory2Ptr ipCF2;

    // Standard COM creation function. Used to obtain a class
    // factory for a particular object
    // (in this case, the map control i.e. Map.)
    HRESULT hr = ::CoGetClassObject(__uuidof(Map), CLSCTX_ALL,
    IID_IClassFactory2, (void**)&ipCF2);

    if (FAILED(hr))

    // The license key.
    _bstr_t bKey (L"Copyright (c) 1999 ESRI, Inc.");

    // Create an instance of the Map control, request IOleControl
    //interface initially.
    IOleControlPtr ipOleControl;
    ipCF2->CreateInstanceLic(0, 0, IID_IOleControl, bKey,

    // IOleControl is used to add controls into their
    // containing frame application.

Article ID:000006264

  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic