CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 1999
    Location
    Germay, Baden-Württemberg
    Posts
    18

    How to publish resource in extension-DLLs to the EXE?

    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: [email protected]
    Borsigstr. 10 Phone: (+49)711-89661-144
    D-70469 Stuttgart Fax: (+49)711-89661-107

  2. #2
    Join Date
    May 1999
    Location
    Toulouse, France
    Posts
    171

    Re: How to publish resource in extension-DLLs to the EXE?

    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.
    We're talking ****, 'cause life is a 'biz
    You know it is
    Everybody tryin' to get rich
    God ****!
    All I wanna do is live !

    KoRn, Children of the Korn

  3. #3
    Join Date
    Apr 1999
    Location
    Germay, Baden-Württemberg
    Posts
    18

    Re: How to publish resource in extension-DLLs to the EXE?

    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: [email protected]
    Borsigstr. 10 Phone: (+49)711-89661-144
    D-70469 Stuttgart Fax: (+49)711-89661-107

  4. #4
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: How to publish resource in extension-DLLs to the EXE?

    See post 1286 on this board. I would copy it but it's kind of long.



  5. #5
    Join Date
    Apr 1999
    Location
    Germay, Baden-Württemberg
    Posts
    18

    Re: How to publish resource in extension-DLLs to the EXE?

    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: [email protected]
    Borsigstr. 10 Phone: (+49)711-89661-144
    D-70469 Stuttgart Fax: (+49)711-89661-107

  6. #6
    Join Date
    May 1999
    Location
    Toulouse, France
    Posts
    171

    Re: How to publish resource in extension-DLLs to the EXE?

    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.
    We're talking ****, 'cause life is a 'biz
    You know it is
    Everybody tryin' to get rich
    God ****!
    All I wanna do is live !

    KoRn, Children of the Korn

  7. #7
    Join Date
    Apr 1999
    Posts
    383

    Re: How to publish resource in extension-DLLs to the EXE?

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured