Click to See Complete Forum and Search --> : How to publish resource in extension-DLLs to the EXE?
Erich Hermann
April 6th, 1999, 09:12 AM
I use an Extension-MFC-DLL that contains functions and resources. When I want to access a resource from within my EXE, the search order is EXE, ext-DLL, MFC-DLL for the resources.
But how to I publish my ext-DLL resource-constants to the exe. Including resource.h of my ext-DLL into the EXE-code leads to redefinitions of constants.
What is the correct philosophy?
Erich
_____________________________________________________________________
anti-spam: remove dashes in mail-adress to send mail
Erich Hermann
ETAS GmbH & Co. KG e-mail: ---Erich.Hermann@ETAS.de
Borsigstr. 10 Phone: (+49)711-89661-144
D-70469 Stuttgart Fax: (+49)711-89661-107
Karl
April 6th, 1999, 09:18 AM
one way is to use the WIN32 Api, and specify the hInstance you need. For example:
HINSTANCE hInstance = GetModuleHandle("myDll");
char buffer[1024];
::LoadString(hInstance, IDS_MY_STRING, buffer, 1024);
HTH
K.
Ash to ash and clay to clay, if the enemy doesn't get you, your own folk may.
Erich Hermann
April 6th, 1999, 12:04 PM
this is not the point. I know how to use e.g. LoadString and how to specify different handles for different modules.
The problem is, a resource-constant e.g. IDS_MY_STRING ist defined in the resource.h of the extension-dll. Now I want to load the string from code from within the exe, i.e. LoadString(IDS_MY_STRING). But, the problem is, the symbolic constant IDS_MY_STRING is not known in the context of the exe.
_____________________________________________________________________
anti-spam: remove dashes in mail-adress to send mail
Erich Hermann
ETAS GmbH & Co. KG e-mail: ---Erich.Hermann@ETAS.de
Borsigstr. 10 Phone: (+49)711-89661-144
D-70469 Stuttgart Fax: (+49)711-89661-107
Gomez Addams
April 6th, 1999, 12:56 PM
See post 1286 on this board. I would copy it but it's kind of long.
Erich Hermann
April 7th, 1999, 03:29 AM
Still not the point I'm looking for.
Like in my example, I have a string defined in my DLL, referenced by the symbol IDS_MY_STRING. This symbol is defined in the DLL-resource.h like:
#define IDS_MY_STRING 10000
From within my EXE I want to load this string, e.g.
CString s; s.LoadString( IDS_MY_STRING );
Since the resource number 10000 is not present in my exe, the framework loads the string from my extension-DLL. Fine.
But the problem is, the symbol IDS_MY_STRING is not known in my EXE, because I cannot include the DLL's-resource.h (it defines several other constants that interfere with constants of the same name in the exe's-resource.h).
So what is a common solution to get only a part of the DLL's-resource.h included in the exe???
Erich
_____________________________________________________________________
anti-spam: remove dashes in mail-adress to send mail
Erich Hermann
ETAS GmbH & Co. KG e-mail: ---Erich.Hermann@ETAS.de
Borsigstr. 10 Phone: (+49)711-89661-144
D-70469 Stuttgart Fax: (+49)711-89661-107
Karl
April 7th, 1999, 04:06 AM
1) you may use #ifdef in your include file to have what you want in your dll and in your exe, using preprocessor definitions.
2) you may define a function in your dll which load the good resource (take care of hInstance). This function may be called by your exe;
K.
Ash to ash and clay to clay, if the enemy doesn't get you, your own folk may.
Dave Lorde
April 7th, 1999, 08:17 AM
Have a look at AfxSetResourceHandle( HINSTANCE hInstResource );
Use this function to set the HINSTANCE handle that determines from where the default resources of the application are loaded.
Dave
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.