Jump to content
Sign in to follow this  

Example DLL in C++ Visual Studio

Recommended Posts


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


#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


Add @1

In Solution Explorer Header Files->Right mouse->Ad->New Item->Code->Header File (.h)->Name ExampleDLL->Add

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)

Feed Polish children: pajacyk - just go to this page and close it. Thanks. World website: free rice.

Share this post

Link to post
Share on other sites

this example not working... I did exactly what you wrote ... Any ideas why ?

$Add = DllCall(@ScriptDir &"ExampleDLL.dll", "int", "Add", "int", 10 ,"int", 9)


[RU] Zone

Share this post

Link to post
Share on other sites

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])

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...