Jump to content

Creating a DLL in C++ for AutoIt


Recommended Posts

Yeah I usually compile dll's in C++ and use them in AutoIt. Pretty nice when you need speed or multi-threading :)

Here's an example:

Fire up your C++ environment and start a new dll project then copy and paste this code and compile:

extern "C" int __declspec(dllexport) TestFunc (int a)
{
    return a*2;
}

You can then call the resulting dll in AutoIt like this:

$call=DllCall("thenameofthedll.dll","int:cdecl","TestFunc","int",5)
MsgBox(0,"5*2 is:",$call[0])

Good luck :o

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

Link to comment
Share on other sites

OK one more Question...

I tried to make a simple class in my DLL but it did not work...

How to do this?

And how do you use it in AutoIt then?

Is it possible?

You cannot interact with classes in autoit* so you need to abstract that away in your exported functions. If you need to pass classes between calls use pointers instead.

* It's possible to call methods and such but it's not very nice and clean and is more job than just rethinking your logic in the dll.

Edited by monoceres

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