Resource Management

Resource management is an important consideration when designing an ObjectARX application that uses an MFC library shared with AutoCAD and other applications.

You must insert your module state (using CDynLinkLibrary) into the chain that MFC examines when it performs operations such as locating a resource. However, it is strongly recommended that you explicitly manage your application's resources so that they will not conflict with other resources from AutoCAD or other ObjectARX applications.

To explicitly set resources

  1. Before taking any steps that would cause MFC to look for your resource, call the AFX function AfxSetResourceHandle() to set the custom resource as the system default.
  2. Before setting the system resource to your resource, call AfxGetResourceHandle() to get and store the current system resource handle.
  3. Immediately after performing any functions that require the custom resource, the system resource should be reset to the resource handle previously saved.

When calling AutoCAD API functions or invoking AutoCAD commands that need AutoCAD's resources, such as acedGetFileD(), be sure to set the resource back to AutoCAD before making the function call. Restore your application's resource afterwards. Use acedGetAcadResourceInstance() to get AutoCAD's resource handle.