CompuServe Thread

DLL ExitInstance()

2 messages in this thread
#30301From: John M. UrbanskyJul 8, 1994 2:04 PM
I have a DLL written using MFC 2.0 on WIndows NT. When the client app attaches to the DLL, the DLL's CWinDLL::InitInstance() method gets called, and all is well with the world. However, when the application is closed, any code I have in the CWinDLL destructor is run, but any code I place in CWinDLL::ExitInstance() doesn't get called at all. If I write the DLL straight SDK with LibMain(), the PROCESS_DETACH case gets called normally. Isn't ExitInstance() just a wrapper for the PROCESS_DETACH case?
#30592From: Mary Kirtland [MFCJ]Jul 11, 1994 8:43 PM
John, This is a bug in the NT version of MFC2.0. I believe ExitInstance() is *supposed* to be called in the PROCESS_DETACH case for DllMain(), but it isn't. Basically, you need to write your own DllMain(). I'm pretty sure you just need to modify the case for dwReason == DLL_PROCESS_DETACH to call ExitInstance() if there is an application object, before AfxWinTerm() is called. But I don't have the code in front of me, so you might check the KB to see if this problem has made it in yet… Hope this helps, Mary Kirtland MFCJournal