I agree that it's not a good idea to load DLLs from within DllMain(). It
often leads to problems. However, all the reasons I've ever seen listed do
not apply to resource-only DLLs. Now, of course, I probably haven't read
about all of them...
Serge.
"Emmanuel V." <everguet@gmail.com> wrote in message
news:2d884b8f-fb08-45c0-9ba5-9db59d93baef@r60g2000hsc.googlegroups.com...
Hello,
I have resource DLLs (for example AppXXX.dll) to localize my
applications (App.exe), but I want to localize some MFC DLLs too. For
example Library.dll which is dynamicaly loaded by App.exe, need to be
localized. So I want to create a localized LibraryXXX.dll.
I'm using LoadLibrary("AppXXX.dll") and AfxSetResourceHandle() for my
EXE and it's working. I tried the same code in DLL_PROCESS_ATTACH in
the DllMain of Library.dll (to load resource only LibraryXXX.dll).
It's not working, I still have the default language.
I notice that, in the DLL_PROCESS_ATTACH, after LoadLibrary() and
AfxSetResourceHandle(), if I call LoadString, I get the localized one.
But when calling the same LoadString, from my EXE, I get the default
one as if I never call LoadLibrary() and AfxSetResourceHandle() from
DllMain()...
Can you help me to localize a DLL into resource only DLLs ?
It is recommended you don't call LoadLibrary() from within DllMain().
Since your DLL is in the process of being loaded, I think Windows has
locked the loader in your process and therefore other DLL's cannot be
loaded at this time. Can you defer this code until sometime after your
DllMain is run? Perhaps you could export a function from your DLL that
the .exe could call after your DLL is loaded by the .exe.
-- David