Losing resource using LoadLibrary and FreeLibrary
Sanjay -- SGUPTA@aegonusa.com Friday, January 19, 1996 I am having this strange problem. I have this MDI app in VC1.52 and a user DLL. In response to a menu command, I use LoadLibrary to load the DLL, then call a function from the DLL, and then use FreeLibrary to free the DLL. The function I call from the DLL does nothing but simply displays a small dialog box. What I find is that I lose resources just by LoadLibrary, calling a function which virtually does nothing, and then FreeLibrary. Does anybody know why do I lose resources. just by loading and freeing a user DLL. I really need help in this. Thanks in advance! Sanjay Gupta SGUPTA@AEGONUSA.COM
Ron Birk -- rbirk@ctp.com Tuesday, January 23, 1996 [Mini-digest: 4 responses] > FreeLibrary. Does anybody know why do I lose resources. just by loading > and freeing a user DLL. One common misstake is to forget to declare the WEP in the .def file. This will cause resource leakage. Ron -- /\/\ Ron Birk Email: rbirk@ctp.com / /_ \ Horizontal Solutions Tel: +46 8 744 6119 \ / / Cambridge Technology Partners Fax: +46 8 744 9933 \/\/ Stockholm, Sweden Voicemail: +1 617 374 2081 -----From: Amir SalzbergWhat do you mean by "displays a small dialog box"? Did you free the dialog box resource? -----From: sunil@teil.soft.net (Mahale Sunil Pramod) Hello Sanjay In the question you need to specify under which operating you are working. Since I had similar problems running under Windows 3.1. The resources used to be damaged but under Windows 95 it used to work perfectly. SUNIL -----From: Dave Tucker MSVC 1.52 shipped with a bug in the MFC USRDLL code where 3 pens were = allocated but never released. This was fixed with MSVC 1.52b. This may = be your problem if the DLL you are loading is an MFC USRDLL type. If = you don't have 1.52b you can place the following code in your USRDLL = ExitInstance routine to free the pens. Note: you must include the MFC auxdata.h file to get access to the = global auxData struct. #include CMyDLL::ExitInstance() ... ::DeleteObject ( afxData.hpenBtnHilite ); ::DeleteObject ( afxData.hpenBtnShadow ); ::DeleteObject ( afxData.hpenBtnText ); afxData.hpenBtnHilite =3D 0; afxData.hpenBtnShadow =3D 0; afxData.hpenBtnText =3D 0; =09 return CWinapp::ExitInstance();
Martijn Vels -- Vels0020@exact.nl Tuesday, January 23, 1996 Well, I don't no if this is your problem, but check if the MFC-LibMain/WEP is called where cleanup is done. We had some problems because LibMain/WEP calls came from the wrong object en library. (Import library made without /NOWEP and taken first by the linker....) >M< ---------- From: owner-mfc-l To: 'MFC-L' Subject: Losing resource using LoadLibrary and FreeLibrary Date: Friday, January 19, 1996 4:06PM I am having this strange problem. I have this MDI app in VC1.52 and a user DLL. In response to a menu command, I use LoadLibrary to load the DLL, then call a function from the DLL, and then use FreeLibrary to free the DLL. The function I call from the DLL does nothing but simply displays a small dialog box. What I find is that I lose resources just by LoadLibrary, calling a function which virtually does nothing, and then FreeLibrary. Does anybody know why do I lose resources. just by loading and freeing a user DLL. I really need help in this. Thanks in advance! Sanjay Gupta
| Вернуться в корень Архива |