The main entry point of the add-on.

    GSErrCode  Initialize (


Return Values

The initialization procedure has completed with success.



You can use this function as the main entry point of your code. It is called by the library right after the DLL/code fragment has been loaded into the memory, and the communication channels are set up correctly.

This is the place where you can initialize your global variables, dynamic memory blocks etc.

In this function you will also have to install the callback functions for the different services you registered in the CheckEnvironment and RegisterInterface routines. Also you can install the notification handlers here.

Featuring API 10  If your add-on has user interface, and you want to use a context sensitive help engine (you want to use not just tooltips, but help anchors too), then this is the place where you can register your own help engine’s path with your add-on’s MDID (see DG::RegisterAdditionalHelpLocation in the example code).



typedef struct {
   double   len;
   Int32     index;
} NType;

GSHandle  **handle;
Int32     nAlloc;
Int32     nElem;

// -----------------------------------------------------------------------------
// Called after the Add-On has been loaded into memory
// -----------------------------------------------------------------------------
GSErrCode    __ACDLL_CALL Initialize (void)

    // If the add-on has user interface and wants to use context sensitive help engine
    IO::Location helpLoc;
    ACAPI_GetOwnLocation (&helpLoc);
    DG::RegisterAdditionalHelpLocation (MDID_DeveloperID, MDID_LocalID, helpLoc);

    // Allocate globals
    nAlloc = 8;
    nElem  = 0;
    handle = (NType **) BMhAll (nAlloc * sizeof (NType));
    if (handle == nullptr)
        return APIERR_MEMFULL;

    // Install the menu handler procedure
    GSErrCode err = ACAPI_Install_MenuHandler (32500, MenuCommandHandler);
    if (err != NoError)
        DBPrintf ("Initialize():: ACAPI_Install_MenuHandler failed\n");

    // Install the change defaults notification handler procedure
    API_ToolBoxItem toolBoxItem;
    BNZeroMemory (&toolBoxItem, sizeof (API_ToolBoxItem));
    toolBoxItem.typeID = API_ZombieElemID;                // for all types
    err = ACAPI_Notify_CatchChangeDefaults (&toolBoxItem, APIDefaultsChangeHandler);
    if (err == NoError) {
        err = ACAPI_Notify_CatchProjectEvent (APINotify_Close, APIProjectEventHandler);

    return err;
}   // Initialize



Version: API 4.1 or later
Header: ACAPinc.h


See Also

Required Functions, FreeData
CheckEnvironment, RegisterInterface
API Functions