Jump to content

Create a DLL in C# for autoit


frankito
 Share

Recommended Posts

like this ? http://www.autoitscript.com/forum/index.php?showtopic=39262

my purpose is quite simple i just want to encrypt a large string in a DLL and deserve it to my autoit exe.

Like this :

My DLL :

GetMyString() {

return string

}

My EXE :

Call ("mydll","getMyString")

I know it's not as simple as i could write, but i'm litlle bit lost...

thanks

Link to comment
Share on other sites

No, you're looking in the right place but the wrong direction.

You said you wanted to use C#, so I assume you know enough about Visual Studio to follow this.

[COMVisible(true)]
public class MyCOMClass
{
    public string GetMyString(string someparameter)
    {
        return someparameter;
    }
}

Compile this to "mydll.dll".

Then call "regasm.exe /codebase mydll.dll".

In AutoIt,

$obj = ObjCreate("mydll.MyCOMClass")
$mystring = $obj.GetString("Hello!")

One or more of these steps may need tweaking, but I hope I've at least given you a step in the right direction.

Link to comment
Share on other sites

  • 2 years later...

Compile this to "mydll.dll".

Then call "regasm.exe /codebase mydll.dll".

Am I correct in thinking that this will only allow this solution to work on the computer that it's built on?

Edit:

Well I tested this method out and I have it working on 1 pc and not another. I tried using regasm to generate a registry file for use on the second pc but that didn't seem to help. Any advice on how to get this to work on pcs that it wasn't built on?

Thanks!

Edited by zpanderson
Link to comment
Share on other sites

Thanks a lot for your help on getting this to work.

I do have one more question that you might be able to help with. My c# function takes "public static int put(String[] args)" as an input parameter but I can't figure out how to send this through autoit. I tried making an array of strings, but that doesn't work.

Dim $args[4] = ['OTS.TROUBLECALL.IN', 'OMSDW001', 'SEEBYOND.SVRCONN/TCP/172.19.96.64(1414)', '']

$obj = ObjCreate("nmqput.mqput")
$obj.put($args)

I get a COM Error

err.windescription = Type mismatch.

err.number is: 80020005

err.lastdllerror is: 0

err.scriptline is: -1

err.source is:

err.helpfile is:

err.helpcontext is: 4980844

If I change my c# function to "public static int put(String args)". I can send a singular string with no problems.

Regards,

Edited by zpanderson
Link to comment
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
 Share

  • Recently Browsing   0 members

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