Sign in to follow this  
Followers 0
slax

calling Dllls as quickly as possible

6 posts in this topic

#1 ·  Posted (edited)

Hello everyone,

I have been using autoit for a year but i 've never tried using dlls until now. Well, now i would like to know what is the quickest way of using dll files (calling functions in them).

Currently in order to use a dll I use this code:

$dll = DllOpen ("whatever.dll")

...

DllCall($dll, "return type", "Function", "type1", "param1")

Because the DllCall function is in a loop I need it to be done as quickly as possible.

So here is my question:

Is there a way of calling dll fuctions more quickly?

Thanks in advance

Edited by slax

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Open the DLL before the loop and close it afterwards. I preferably open them on program start and close them on program exit.

I guess more speed improvement can be achived if you load the DLL to memory, search examples section.

Edited by KaFu

Share this post


Link to post
Share on other sites

First of all thanks for your reply. That's what I am doing. I open the dll on program start and not in the loop.

That is what the three dots mean. :-)

Share this post


Link to post
Share on other sites

The speed you achieve with your code is more than enough for most applications (just take a look at the standard library, everything is done with dllcall there).

If you really truly want more speed and know at least some basic assembly then take a look at the various assembly/machine code example spread around the forums ( I believe trancexx call it flying assembly).

However everyone did just fine without it before so I doubt you will realy need it.

I guess more speed improvement can be achived if you load the DLL to memory, search examples section.

What exactly do you think happens when you use DllOpen()?


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

DLLOpen(): "Success: Returns a dll "handle" to be used with subsequent Dll functions."

Had assumed that the DLL is "opened" and a "handle" for communication is created... but from your implicit reply I now assume it's loaded to memory? I'm always willing to learn as a pure spare time "coder"...

Share this post


Link to post
Share on other sites

Yes, just like when you run an exe the entire image gets loaded into system memory and begins to execute at its entry point. The difference between an exe and a dll is that windows maps dll's into the address space of other processes instead of (like exe's) in their own space.

So the dll gets loaded into memory even without the use of DllOpen it's just autoit that hides the loading/unloading each time.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
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
Sign in to follow this  
Followers 0