Jump to content

How Call in Autoit function Library (dll) C#


Recommended Posts

Hello,

I have project Class Library in VS C# and I want call this function "Add"

but I still have error 3 - "function" not found in the DLL file.

How fix it ?

>>Code in VS C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClassLibrary1
{
    public class Class1
    {

        public int Add(int p1, int p2)
        {
            return p1 + p2;
        }
        public int Subtract(int p1, int p2)
        {
            return p1 - p2;
        }
    }
}

>>Code in AutoIt

$h = ""&@ScriptDir &"\ClassLibrary1.dll"
$Add = DllCall(""&$h, "int", "Add", "int", 3, "int", 4)

    If @error <> 0 Then
        MsgBox(0,""&$Add,"error: "&@error)
    Else
        MsgBox(0,"",""&$Add)
    EndIf

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

Link to post
Share on other sites

This is how best to choose a project in VS to create a library that will work with AutoIt?

If you want to keep it in C#, you should check out the Unmanaged Exports project. It is a project template that allows native consumption of managed DLLs without the typical compilation/deployment overhead. You decorate your methods with a specific attribute and...voila!

Have I used it before? No. Just Google-foo. May be worth checking out.

Best,

Zach...

Edited by zfisherdrums
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...