Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Can't load string from resource DLL's string table

s_ks_k Posts: 57Member
Hi, I use resource DLLs to provide multilingual environment to users - user select language, I call AfxSetResourceHandle() with handle of relevant DLL and in all functions that load some kind of resource, I use AfxGetResourceHandle().

It works great (I have six resource DLLs now + base project, which is in english).

Of course I use same resource symbols in resource.h, with the same values.

But sometimes happens that I'm not able to load certain string from string table of one of DLLs. It has the same value assigned in resource.h as in all others DLLs but it just doesn't work. The only thing that helps that I must add new string to all DLLs and change the code to use this symbol instead of the old one.

I really don't understand what the problem is

What could be the reason?

Have you ever met some similar problem?

Comments

  • weiccoweicco Posts: 950Member
    : Hi, I use resource DLLs to provide multilingual environment to users - user select language, I call AfxSetResourceHandle() with handle of relevant DLL and in all functions that load some kind of resource, I use AfxGetResourceHandle().
    :
    : It works great (I have six resource DLLs now + base project, which is in english).
    :
    : Of course I use same resource symbols in resource.h, with the same values.
    :
    : But sometimes happens that I'm not able to load certain string from string table of one of DLLs. It has the same value assigned in resource.h as in all others DLLs but it just doesn't work. The only thing that helps that I must add new string to all DLLs and change the code to use this symbol instead of the old one.
    :
    : I really don't understand what the problem is
    :
    : What could be the reason?
    :
    : Have you ever met some similar problem?
    :

    I use this kind of approach for my resource DLLs...

    I made a class that holds information about resources and resource DLLs. There is simple Load(LPCTSTR filename) method that loads DLL into memory with LoadLibrary call. Then there is GetString(DWORD dwId) method that loads strings. It goes through the DLLs and tries to load string with LoadString function. If string is found it returns it, if not it continues to next DLL. If string isn't found in any of the DLLs it tries to load string from EXE's resource table. If string isn't even there it returns something like "error: not found".

    This way I have never had any problems with resources (*knocks wood*).
  • s_ks_k Posts: 57Member
    : : Hi, I use resource DLLs to provide multilingual environment to users - user select language, I call AfxSetResourceHandle() with handle of relevant DLL and in all functions that load some kind of resource, I use AfxGetResourceHandle().
    : :
    : : It works great (I have six resource DLLs now + base project, which is in english).
    : :
    : : Of course I use same resource symbols in resource.h, with the same values.
    : :
    : : But sometimes happens that I'm not able to load certain string from string table of one of DLLs. It has the same value assigned in resource.h as in all others DLLs but it just doesn't work. The only thing that helps that I must add new string to all DLLs and change the code to use this symbol instead of the old one.
    : :
    : : I really don't understand what the problem is
    : :
    : : What could be the reason?
    : :
    : : Have you ever met some similar problem?
    : :
    :
    : I use this kind of approach for my resource DLLs...
    :
    : I made a class that holds information about resources and resource DLLs. There is simple Load(LPCTSTR filename) method that loads DLL into memory with LoadLibrary call. Then there is GetString(DWORD dwId) method that loads strings. It goes through the DLLs and tries to load string with LoadString function. If string is found it returns it, if not it continues to next DLL. If string isn't found in any of the DLLs it tries to load string from EXE's resource table. If string isn't even there it returns something like "error: not found".
    :
    : This way I have never had any problems with resources (*knocks wood*).
    :

    Well, but I have these DLLs so that user can simply switch between languages (1 DLL = 1 language). So I always load just one DLL, according to the language selected. So the situation that needed string isn't found in relevant DLL, is unacceptable for me. I KNOW the string is there in the DLL. But sometimes it can't load that string from the DLL and the only thing that helps is to create new strings entry in String table (of all DLLs, of course) with new identificator and change the source code to use this new identificator instead of the old one.
Sign In or Register to comment.