COM wrappers can be created as separate DLLs, or combined with your ObjectARX application. A separate DLL allows the system to manage resources more efficiently; it can release COM objects when they are not needed even if the ObjectARX application cannot be unloaded. A combined DLL may be convenient if you intend to support only in-process clients. In either case, you can use the Microsoft Visual C++ ATL project setup interface to simplify the process. The following sections provide procedures that apply to both types of wrappers:
This procedure sets up the basic COM framework for your wrapper application, including an IDL file and a DLL housing for the object.
In the next procedure, you add a new interface. Microsoft Visual C++ creates a skeletal interface definition and its corresponding COM class. Later, you can add methods and properties to this interface.
The wizard supplies default values for the remaining names. You can modify the suggested names if you wish.
The following procedure configures your project to work with AutoCAD Automation.
Follow the next procedure only if you are combining ObjectARX code with the COM wrapper.
acrxEntryPoint PRIVATE acrxGetApiVersion PRIVATE
In the acrxEntryPoint() function, add a call to DllRegisterServer in the kInitAppMsg case block, as shown below. (This step is not necessary if you are certain your server is registered.)
case AcRx::kInitAppMsg: //unlock the application acrxDynamicLinker->unlockApplication(pkt); acrxRegisterAppMDIAware(pkt); //register ourselves DllRegisterServer(); break;
If other initialization or cleanup occurs in the acrxEntryPoint() function, move this initialization to your DllMain.
Choose “Rebuild All” from the Build menu to build your combined COM wrapper DLL file.