Jump to content
Sign in to follow this  
GrungeRocker

Creating a DLL in C++ for AutoIt

Recommended Posts

GrungeRocker

As said in the Topic, I want to make a DLL with C++ which should be used with AutoIt.

Is there something special I have to mind?

Did someone gain some experience? Anyone got Sourcecode (AutoIt & C++)?


[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Share this post


Link to post
Share on other sites
monoceres

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!

Share this post


Link to post
Share on other sites
GrungeRocker

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?


[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Share this post


Link to post
Share on other sites
monoceres

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!

Share this post


Link to post
Share on other sites
GrungeRocker

OK thx

Good to know =)


[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

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  

×