CoderDunn Posted April 23, 2010 Posted April 23, 2010 (edited) I'm taking an intermediate C++ course in college, and I'm wondering how to write a DLL that can be called within AutoIt3. I tried to make a very simple dll with a function that adds two integers, however when I try to call it from within AutoIt, the script either locks up or throws an error 3 ("function" not found in the DLL file). I was able to compile an AutoIt plugin that worked fine, but I can't get a standard DLL to work ... Here is the dll (test dll.cpp): __declspec(dllexport) int TestFunc(int x, int y) { return x + y; } And here is the script: $dll = DllOpen("Test DLL.dll") if (@error) Then FatalError("Unable to open DLL") $result = DllCall($dll, "int", "TestFunc", "int", 3, "int", 4) if (@error) Then FatalError("Error calling DLL: " & @error) MsgBox(0, "Result", $result[0]) Func FatalError($msg) MsgBox(0, "Fatal Error", $msg) Exit EndFunc Any help would be much appreciated. Thanks, Andy Edited April 30, 2010 by CoderDunn
wraithdu Posted April 23, 2010 Posted April 23, 2010 What calling convention are you using in your project settings? If cdecl, then your second argument to DllCall has to be "<return_type>:cdecl".
CoderDunn Posted April 23, 2010 Author Posted April 23, 2010 (edited) What calling convention are you using in your project settings? If cdecl, then your second argument to DllCall has to be "<return_type>:cdecl". I figured it out, thanks! I changed the function to use a stdcall and a .def file to export the function, and now it works int _stdcall TestFunc(int x, int y) { return x + y; } Edited April 23, 2010 by CoderDunn
Rajucm Posted August 15, 2010 Posted August 15, 2010 (edited) me too still facing same problem It will be great help If you can post your vc++ dll source code.. Edited August 15, 2010 by Rajucm
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now