CoderDunn 1 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 Share this post Link to post Share on other sites
wraithdu 83 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". Share this post Link to post Share on other sites
CoderDunn 1 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 Share this post Link to post Share on other sites
Rajucm 0 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 Share this post Link to post Share on other sites