Unable to Load DLL error

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Unable to Load DLL error

Post by kpassaur » Mon Apr 10, 2006 7:07 pm

I am trying to use Image2PDF which is a DLL that converts images into PDF files. I have contacted
the creator of the software and provided him with the help section of Macro Scheduler that covers
LibFunc. He suggested the following (see below), neither of which worked.

The first returns an error when Macro
Scheduler's debug hits the first line. The second "with the A" generates Unable to load DLL; HOWEVER,it
loads the first line and the debugger watch list says CREPDF=268435456, when the second line hits it says
"C:\TEMP\TEST.PDF" Unable to load DLL

Has anyone tried Image2PDF with Macro Scheduler or have any ideas as to what is wrong


--------------------------MY Script----------------------------------
Let>lib=c:\temp\Image2PDF.dll
LibLoad>lib,crepdf
LibFunc>crepdf,I2PDF_AddImageA,"c:\temp\test.jpg"
LibFunc>crepdf,I2PDF_MakePDFA,"c:\temp\test.pdf",1,0,0
LibFree>crepdf
Goto>EOF
-----------------Suggested from vendor of DLL--------------------------------


From the documentation below I think that the following should work:

LibFunc>Image2PDF,I2PDF_AddImage,"c:\images\test.jpg"
LibFunc>Image2PDF,I2PDF_MakePDF,"c:\test.pdf",1,0,0

If not, then try the following instead which adds the letter A to the end of each call:
LibFunc>Image2PDF,I2PDF_AddImageA,"c:\images\test.jpg"
LibFunc>Image2PDF,I2PDF_MakePDFA,"c:\test.pdf",1,0,0



------------------------------ Portion of manual that covers add and create options---------------


I2PDF_AddImage
Parameters: image - can be one of the following types: JPG, TIF, PNG, GIF, BMP, PCX or TGA
Return Value: 0 - success
1 - invalid parameter
2 - maximum number of images already added
3 - invalid image type
Notes: Specifies the name and location of an image to embed within the output PDF document.
Up to 1000 images can be included.
Images are embedded in the output PDF document in the order that they are referenced.
Multi-image TIFF images are supported so that each image within the TIFF is placed on
their own PDF page.
Animated GIF images are supported so that each frame within the animated GIF is placed
on their own PDF page.



I2PDF_MakePDF
Parameters: output - specifies the name and location of the output PDF document
options - can be any combination of: OPTION_NONE, OPTION_OPEN_PDF (open
produced PDF in default PDF viewer) and OPTION_RESET (resets all settings apart from
the License Code)
errorText - string/byte array buffer that any internal PDF generation error is returned
into
errorMaxLen - maximum error text buffer length
Return Value: 0 - success
1 - invalid parameter
2 - output pdf could not be opened
3 - internal PDF generation error - error description returned in errorText
4 - PDF file already exists and could not be overwritten - it is possibly being held open by
a PDF viewer application
Notes: Generate the output PDF according to the settings already selected through the
Application Programming Interface functions.
Note: When this has been called, all previous settings made (apart from the License Code)
are reset ready for the settings to be made for the next PDF that is to be generated.
------------------------------------------------------------------------------------
This would be a great DLL to use with Macro Scheduler as it is very affortable and powerful.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Apr 11, 2006 9:01 am

You are missing the return variable. LibFunc requires the DLL name or handle, then the function name, then a return var and then the parameter list. So you need this:

LibLoad>lib,crepdf
LibFunc>crepdf,I2PDF_AddImageA,result,c:\temp\test.jpg
LibFunc>crepdf,I2PDF_MakePDFA,result,c:\temp\test.pdf,1,0,0
LibFree>crepdf

You also shouldn't need the quotes unless the DLL is expecting them.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Not loading the DLL

Post by kpassaur » Tue Apr 11, 2006 9:41 am

I tried what you suggested and it still did not work and I contacted the vendor again as well. The vendor suggested that I put the dll in the path so I dropped it in Windows\System32 and used this script

Iffileexists>c:\windows\system32\Image2PDF.dll
Let>lib=c:\windows\system32\Image2PDF.dll
LibLoad>lib,crepdf
LibFunc>crepdf,I2PDF_AddImageA,addresult,"c:\temp\test.jpg"
LibFunc>crepdf,I2PDF_MakePDFA,makeresult,"c:\temp\test.pdf",1,0,0,
MDL>%addresult%%CRLF%%makeresult%
LibFree>crepdf
Endif
Goto>EOF

The Quotes were put in by the vendor, so I assume (yes I know) that they are required; however, I got the same error message with and without them.

Unable to Load DLL

Any ideas as to what to try next? Oh yes and thank you for your help

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Apr 11, 2006 12:55 pm

Strings in Macro Scheduler do not require quotes so I'm not convinced you need them.

Anyway, if you get "Unable to load DLL" then the dll cannot be found or the function name is wrong or does not exist.

However, I think you are saying the first cal works but the second fails. I can see one error with your second call. According to the instructions you posted the penultimate parm should be a string buffer, but you have an integer. I would expect that to generate an error.

Try:

LibLoad>lib,crepdf
LibFunc>crepdf,I2PDF_AddImageA,result,c:\temp\test.jpg
Let>errbuf=
Let>errbuf_SIZE=255
LibFunc>crepdf,I2PDF_MakePDFA,result,c:\temp\test.pdf,1,errbuf,255
LibFree>crepdf
MessageModal>result

What is the value of result at the end?

You should also confirm what the numeric values of the OPTION_ vars are. Above the number 1 is supplied but the documentation supplied does not state whether this is right or not.

Without a copy of the DLL and docs I cannot help much more than that. Feel free to send the DLL and docs to support so that they can test it out. But on the basis of the info you have supplied so far I see no reason why it shouldn't work.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Dll still does not load

Post by kpassaur » Tue Apr 11, 2006 2:13 pm

That didn't work either. I have tried putting the dll in the same folder as the script (I compiled it) which was suggested by the author and in the System32 folder.

I will send it all to support and post what they find as I think this will be a very usefull dll for others.

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Works now

Post by kpassaur » Tue Apr 11, 2006 8:30 pm

The working script is here, I messed up on posting

http://www.mjtnet.com/forum/viewtopic.p ... =load+dll

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts