question on resource only DLL
edwardlau@hactl.com.hk Tuesday, July 23, 1996 Environment: VC++ 4.0 under Win 95 I have built a resource only DLL. What it has included is a string table only. How can I specify to use the string resource in the DLL instead of the project's own? Do I have to declared something external for I encounter undeclared identifier when compiled? Moreover, can I use the project's own resource in addition to the DLL's?? Thanks.... Edward, PEI, edwardlau@hactl.com.hk
Bruce R. Cochran -- brc@colossus.Storz.Com Friday, July 26, 1996 [Mini-digest: 3 responses] Environment: VC++ 4.2 under Win 95 To load the resource file you need to get a handle to the resource only dll and use the AfxSetResourceHandle routine to set this file to be used as the one for the resources.(like shown below) HINSTANCE m_hResource; // handle to resource file m_hResource = LoadLibrary("Your dll"); AfxSetResourceHandle(m_hResource); // use this file for resources FreeLibrary(m_hResource); If you call AfxSetResourceHandle with NULL as the handle it will use the projects resources. ---------- From: edwardlau@hactl.com.hk[SMTP:edwardlau@hactl.com.hk] Sent: Tuesday, July 23, 1996 5:12 AM To: mfc-l@netcom.com Subject: question on resource only DLL Environment: VC++ 4.0 under Win 95 I have built a resource only DLL. What it has included is a string table only. How can I specify to use the string resource in the DLL instead of the project's own? Do I have to declared something external for I encounter undeclared identifier when compiled? Moreover, can I use the project's own resource in addition to the DLL's?? Thanks.... Edward, PEI, edwardlau@hactl.com.hk -----From: David.Lowndes@bj.co.uk Edward, You don't say what undeclared id's you're getting! You can use your application's resources as well as the DLL's. I assume you're using an MFC application If so, you need to ensure that you save the instance handle of the DLL so that when you want to use a resource in the DLL you switch to using that instance handle rather than the one of your application. Have a look at TN033 in the on-line help. Here's a snippet from it: "If you wish to only load resources from a specific place, use the APIs AfxGetResourceHandle and AfxSetResourceHandle to save the old handle and set the new handle. Be sure to restore the old resource handle before you return to the client application. The sample TESTDLL2 uses this approach for explicitly loading a menu." Dave Lowndes -----From: wayne.dengel@octel.com I did it by putting the following in InitInstance in TheApp if(_access("Language.DLL",00)==0){ MessageBox(NULL,"Loading Extension Language DLL","START-UP",MB_OK); AfxSetResourceHandle(AfxLoadLibrary("Language.DLL")); } From this point on ALL resources come from this DLL, if a resource is called that does NOT exist, then it comes from the standard RESOURCE in the project itself. Hope this helps. Wayne
Vincent Mascart -- 100425.1337@compuserve.com Tuesday, July 30, 1996 >From: Bruce Cochran >Sent: lundi 29 juillet 1996 10:07 >To: "'mfc-l@netcom.com'" >Subject: RE: question on resource only DLL > > Environment: VC++ 4.2 under Win 95 > >[snpi] > > If you call AfxSetResourceHandle with NULL as the handle it will use the >projects resources. Maybe that's true with VC++ 4.2, but previous versions of VC++ will assert. Since I don't have VC ++ 4.2, I couldn't verify if it assert or not. Maybe is it worth to check it ... Vincent Mascart 100425.1337@compuserve.com
| Вернуться в корень Архива |