Print Page | Close Window

LIB edition DllMain

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1896
Printed Date: 20 May 25 at 1:26PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: LIB edition DllMain
Posted By: maureen
Subject: LIB edition DllMain
Date Posted: 21 Jul 11 at 5:34PM
What is the full, correct syntax for calling the QUICKPDFLIBXXXX_DllMain() function when using the LIB edition of QPL? Specifically, what should the first parameter be?

I am trying to link the LIB into a C++ DLL which is then called by an EXE. I have tried QUICKPDFLIB0726_DllMain(GetModuleHandle(NULL), DLL_PROCESS_ATTACH, NULL) as per the Getting Started guide, which will pass a handle to the EXE. I have also tried passing the handle to my DLL, which I get as the first parameter to my DLL's DllMain(). Both cause QUICKPDFLIB0726_DllMain() to crash.

Can anyone offer a suggestion? Thanks very much in advance.



Replies:
Posted By: maureen
Date Posted: 21 Jul 11 at 6:49PM
Additional information...

Linking the LIB straight into an EXE and initialising it with QUICKPDFLIB0726_DllMain(GetModuleHandle(NULL), DLL_PROCESS_ATTACH, NULL) works just fine.

When I produce a release build of my DLL and EXE and run the EXE, it crashes and shows the Windows "this program has crashed" message, followed by a message box that says "Runtime Error 217 at 1001B6D1". This is the same for any handle value I pass.

Again, many thanks in advance for any suggestions.


Posted By: AndrewC
Date Posted: 22 Jul 11 at 8:54AM
The LIB file that we supply is created with a 3rd party tool that takes a DLL and makes a LIB file from it so it probably uses some tricks which are getting in the way of allowing us to add the LIB file to a DLL.

As you know, QPL is complied in Delphi.  Delphi creates a different object file format to MSVC (COFF vs OMF) and so the tool we use does some fancy tricks in order to create a LIB file that is compatible with the Microsoft compilers and their require LIB format.

We are contacting the tool supplier for an answer.




Posted By: Ingo
Date Posted: 22 Jul 11 at 4:08PM
Hi Andrew!

Off topc but ...
"...
The LIB file that we supply is created with a 3rd party tool
..."
Which is the name of these 3rd party tool?
Would be very interesting for me.
Thanks in advance.

Cheers, Ingo



Posted By: tfrost
Date Posted: 22 Jul 11 at 9:51PM
In your own DLL, where have you put the call to load the QuickPDF DLL?  You must not do this in your main DLL entry point, because you are not allowed to recursively load another DLL at this time.  You may need to make another initialization call to the DLL from your main program, after your own DLL load is complete, to get your DLL to load the QuickPDF DLL.  You should also be careful not to unload the DLL from a thread or process detach case in your DLL main entry.


Posted By: maureen
Date Posted: 25 Jul 11 at 12:44PM
Hi tfrost, thanks for the suggestion but unfortunately that's not the problem. The only thing I do in my DllMain() is save the HINSTANCE first parameter to a global variable.


Posted By: AndrewC
Date Posted: 28 Jul 11 at 1:43PM

http://www.binary-soft.com/dll2lib/dll2lib.htm - http://www.binary-soft.com/dll2lib/dll2lib.htm


Posted By: maureen
Date Posted: 04 Aug 11 at 11:57AM
Well, I feel rather foolish. The problem was caused by not including the resource files QuickPDFCMap.res, QuickPDFDingbats.res and QuickPDFGlyphList.res as is quite clearly stated in the Getting Started guide.

For reference, if you're linking the Quick PDF LIB into a DLL, the correct HINSTANCE value to pass as the first parameter to QUICKPDFLIBXXXX_DllMain() is the HINSTANCE of your DLL, which you get passed by Windows as the first parameter of your own DllMain().



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk