Jump to content

DLLOpen failure


jtwspoon
 Share

Go to solution Solved by jtwspoon,

Recommended Posts

I'm trying to use a simple DLL, compiled by Free Pascal, in an AutoIt script, but using the DLLOpen function always results in -1.  I'm sure the path and or name specified  for the DLL  file as the argument to DLLOpen is not the problem. I suspect that DLL's compiled with Free Pascal (or maybe other Pascal's, too) are not usable by AutoIt.  If so, are there any workarounds?  Suggestions?

Link to comment
Share on other sites

  • Moderators

Did you try registering the dll then using dllopen?

This of course is a guess, no code, no dll, no operating system, leads to nothing but guessing.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I tried to register as you suggested, but get this message:

The module "cccrashminmax.dll" was loaded but the entrypoint DllRegisterServer was not found.

Make sure that "cccrashminmax.dll"  is a valid DLL or OCX file and then try again.

 

OK, how can I make sure that it is a valid DLL file?  It compiles without error using Free Pascal to produce the .dll file.

Link to comment
Share on other sites

  • Moderators

That sounds like like a question for their forum??  I've never used "Free Pascal".

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks for the helpful suggestions.   I have verified that I am trying to load a valid DLL. The DLL works fine when its functions are called by a test Free Pascal program.  But it still won't load using either the 64 bit version or 32 bit version of autoit.

Link to comment
Share on other sites

Here is the auoit code:

 

#requireadmin ; run as administrator

 

$hdll = DllOpen("user32.dll")        ; works

msgbox(0,"user32",@error & "  " & $hdll)

$hdlla = DllOpen("minmax.dll")         ; does not work

msgbox(0,"minmax",@error & " " & $hdlla)

 

minmax.dll is in the same directory as this auotit script.  minmax.dll is a  very simple valid workable dll compiled in Free Pascal (64 bit) under Windows 7.  The DLLOpen error occurs when run under both the 64 bit and 32 bit versions of autoit under Windows 7.

Link to comment
Share on other sites

according to post found on forum.lazarus using MyDLL.dll from that post on func MyAddFunction from that dll.

If that dll is compiled using Free Pascal, then autoit works with no problem i think... if i understud code from that files correctly on that post ofc :P

#include <Array.au3>
$dll = DllOpen('MyDLL.dll');dll is located next to script, btw im running 32 bit just for your info :P
$r = DllCall($dll,'uint','MyAddFunction','uint',2,'uint',3);func shud return sum of first and second parametar in arraye[0] (first array element)
If @error Then MsgBox(0,'',@error)
_ArrayDisplay($r);returning result
And if thats the case then you have problems with Pascal side of your code (coding) and not with autoit, or you have problems with 32 vs 64. Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Dont know what is mydllo.dll

but for me MyDLL.dll works correctly when i test it with the script i posted,

if it dont work for you try to put this line on top of my script to see will MyDLL.dll work for you

#AutoIt3Wrapper_usex64=n

i do not know if this directive need full scite version from autoit site, but its allwayes good to instal full scite version.

That shud force not to use 64 in this case

Ask ChrisF on that forum, is mydll.dll compiled with Free Pascal.

If it is ask him if they can provide you with its source, then youl have your answer...

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Try this:

 

#Include <WinAPI.au3>

$hDll = _WinAPI_LoadLibrary('minmax.dll')
If Not $hDll Then
    ConsoleWrite($hDll & ' - ' & _WinAPI_GetLastError() & @CR)
Else
    ConsoleWrite($hDll & ' - ' & '0' & @CR)
EndIf
Link to comment
Share on other sites

  • Solution

I have now identified corrections to my dll to allow it to load with DLLOpen using the 32 bit version of autoit.  However,  it appears that loading with DLLOpen produces a different type of handle than loading as you suggest with _WinAPI_LoadLibrary, which also works.  With DLLOpen, it appears that the handle returned is simply an ordinal integer for the number of Dll's that have been opened. For example if two DLL's have already been opened, then $hdll = DLLOpen("mydll.dll")  will result in a value of 3 for $hdll.  That is  quite different from the handle returned by _WinAPI_LoadLibrary.  If I try to use DLLCall, whether with the handle retrieved by DLLOpen or directly using the dll filename, the autoitscript crashes  --- i.e. the script exits before ever getting to the next line in the script, so can't even check for the type error that might have occurred.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...