Before your application can use any API functions, it must connect to and initialize PC*MILER|Connect. After it finishes, it must shut down the server connection. You must close the server before your application exits or Windows won’t free the resources used by the DLL, nor will it unlock the current license.  

TIP: Do not repeatedly open and close the server. Open the server on startup and close the server on exit. The server should be opened only once per application instance.

Open Connect

PCMSOpenServer will initialize PC*MILER|Connect, check your PC*MILER licenses, load the PC*MILER highway database, and ready the engine for routing calculations. PCMSOpenServer must be called before any other functions in PC*MILER|Connect, with the exception of error handling codes. 

Close Connect

PCMSCloseServer must be the last function called when you’re finished using the engine. PCMSCloseServer will destroy any remaining trips you haven’t deleted with PCMSDeleteTrip, and unload the PC*MILER highway database. After calling PCMSCloseServer, you must call PCMSOpenServer again to reinitialize PC*MILER|Connect before calling any other functions.

Here is the way your application should start and stop Connect

    PCMServerID server;
    /* Pass neither instance handle, nor parent window*/
    server = PCMSOpenServer(0, 0);
    /* Do other processing here. */
    /* Use the server: calculate trips, etc.... */
    /* Shut down the server */

For efficiency, you should start Connect when your application initializes and shut it down when your application exits, rather than every time you want to compute a route. Also, you should only need to open one connection per application. Once the engine is initialized, you can then calculate distances, create trips, and generate reports.