Jump to content
Sign in to follow this  
kmeleon

How Call in Autoit function Library (dll) C#

Recommended Posts

kmeleon

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.

Share this post


Link to post
Share on other sites
monoscout999

Learn first from the AutoIt Help.

Share this post


Link to post
Share on other sites
kmeleon

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


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
Mat

It needs to be a Win32 Dll, so the way I get there (almost certainly not the way you get there) is New Project -> Other Langauges -> Visual C++ -> Win32 -> Win32 Project, and then when the dialog opens you need to tick the radio button that says Dll.

Share this post


Link to post
Share on other sites
zfisherdrums

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.