There may be a situation where your Arx application needs to exit AutoCAD if the license check or some other business logic fails
When aborting, use AcDbHostApplicationServices::fatalError()
Or, acrx_abort() instead of a direct or indirect call to exit().This will allow AutoCAD and other ObjectARX applications to recover as much work as possible. Always use API calls rather than system calls.
It is highly desirable for the RealDWG host application to override this method, and do whatever needs to be done for a clean and graceful shutdown. For example, allowing the user to save some portion of the work in progress, cleaning up memory allocations, and so on are all things that should be done upon a fatal error.
extern "C" AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt) { AcRx::AppRetCode retVal = AcRx::kRetOK; switch (msg) { case AcRx::kInitAppMsg: //acrxDynamicLinker->unlockApplication(pkt); //acrxRegisterAppMDIAware(pkt); //initApp(); // perform license check retVal = checkLicense(); if (retVal == AcRx::kRetOK) { acrxDynamicLinker->unlockApplication(pkt); acrxRegisterAppMDIAware(pkt); initApp(); } else { MessageBox(adsw_acadMainWnd(), L"Application should not be allowed to load.", L"Start-up Error", MB_OK + MB_ICONWARNING); acrx_abort(L"Invalid License: Application Quits Now"); //or //acdbHostApplicationServices()->fatalError(_T("Application is Quitting Now")); return AcRx::kRetError; } break; case AcRx::kUnloadAppMsg: unloadApp(); break; default: break; } //return AcRx::kRetOK; return retVal; }
Recent Comments