Jump to content

Example DLL in C++ Visual Studio


kmeleon
 Share

Recommended Posts

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.

Link to comment
Share on other sites

  • 1 year later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...