Archived

This topic is now archived and is closed to further replies.

Win32 DLL not linking resource files?

This topic is 5008 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there got an issue with DLLs under Win32. I''m using vc6 under W2K. So here is my problem: I got two projects in my workspace. The first is an Win32 Console Application. The second is a Win32 DLL. The DLL uses classes and in the main class there is a DlgProc and a function to call DialogBox. This means I use Resource Templates in my DLL. If I compile the project VC says that it compiles the resource, the sources and then it links all together. (fine) No errors occur. The .plg (html) shows that the linker also got the .res file to link in. The EXE is using the produced .lib file to acces the class via an exported function. Then it accesses a method of the class which will open the dialog. Boom! The DialogBox-Call returns -1. GetLastError = 1812 (ERROR_RESOURCE_DATA_NOT_FOUND) ??? Where is it gone? I changend my linker settings to generate a map file. I thought I can see where the resources are gone. But no resource sections are shown?! Is it something with a C/C++ setting or maybe a linker setting in the DLL??? (I know that there are some project which HAVE resources in their DLLs - so it should work) Some more info ''bout the project: demo.exe - win32 console application - code generation = single threaded - no resource.h or resource.rc in project (should work without) - the way it should work: hGUI = createGUI(); // the exported func hGUI->showDialog(); gui.dll - win32 dynamic link library - exports createGUI - generates .lib (used in EXE) - code generation = multi-theaded dll - resource.h and resource.rc are used - resource.res specified under settings->resources - the way this should work: MyGUI *createGUI() { return new MyGUI; } class MyGUI { public: virtual void showDialog(); private: static BOOL CALLBACK _dialogProc( ... ); }; MyGUI::showDialog() { DialogBox( this->_hInstance, MKINTRES(IDD_DLG), NULL, _dialogProc ); } BOOL MyGUI::_dialogProc( ... ) { ... }

Share this post


Link to post
Share on other sites
Is this->_hInstance equal to the application instance or the DLL''s instance? If the resource is in the DLL it should be the DLL''s instance.

Share this post


Link to post
Share on other sites
Thx dude! That''s it! I only used GetModuleHandle(NULL); in the DLL. But in this case the so called caller is the EXE. And the EXE (as u said) do not have any resource entries... Fixed it to use the DLL as module. Now it works!

SHAME ON ME :D AND LOTS OF THANK YOUS!!!

Share this post


Link to post
Share on other sites