Jump to content

calling Dllls as quickly as possible


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
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!

Link to comment
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"...

Link to comment
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!

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...