kmeleon Posted July 21, 2011 Posted July 21, 2011 Hello Example DLL in Visual Studio File->New Project->Other language->Visual C++ ->Win32->Win32 Project->Name= "ExampleDLL"->OK->Next->Dll->Finish In Solution Explorer Source Code->ExampleDLL.cpp //ExampleDll.cpp #include "stdafx.h" int _stdcall Add( int a, int b ) { return a + b; } In Solution Explorer "Source Code"->Right mouse->Add->New Item->Code->Module-Definition File (.def)->Name "ExampleDLL"->Add //ExampleDLL.def LIBRARY "ExampleDLL" EXPORTS Add @1 In Solution Explorer Header Files->Right mouse->Ad->New Item->Code->Header File (.h)->Name ExampleDLL->Add //ExampleDLL.h int Add(int a, int b); Menu->Build->Build ExampleDLL ;example AutoIT $h = ""&@ScriptDir &"\ExampleDLL.dll" $Add = DllCall(""&$h, "int", "Add", "int", 10 ,"int", 9) If @error <> 0 Then MsgBox(0,""&$Add,"error: "&@error) Else MsgBox(0,"",""&$Add[0]) EndIf Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.
Enforcer Posted August 12, 2012 Posted August 12, 2012 this example not working... I did exactly what you wrote ... Any ideas why ? $Add = DllCall(@ScriptDir &"ExampleDLL.dll", "int", "Add", "int", 10 ,"int", 9) MsgBox(0,"",""&$Add[0]) [RU] Zone
FaridAgl Posted August 12, 2012 Posted August 12, 2012 (edited) A simpler way is using DllExport, no need to def. Edited August 12, 2012 by D4RKON3 http://faridaghili.ir
Enforcer Posted August 12, 2012 Posted August 12, 2012 Can you post an working example please ? :] [RU] Zone
FaridAgl Posted August 12, 2012 Posted August 12, 2012 Ofc but it's 12:40 AM here and I'm going to bed! Tomorrow, I promise. http://faridaghili.ir
FaridAgl Posted August 13, 2012 Posted August 13, 2012 OK, here we go. I have attached a C++ source code, I suggest you using VS (2010) to compile it. You can find the compiled Dll from the Release folder within the attached zip package. The AutoIt part should be like this: Global $sum = DllCall('DllExport.dll', 'int:cdecl', 'Sum', 'int', 5, 'int', 5) MsgBox(0, '', $sum[0]) http://faridaghili.ir
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