Jump to content

DllCall()


Recommended Posts

  • Moderators

Why wouldn't it be possible I think is the better question. Have you tried?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

here is the reason my friend said it would'nt work:

"native dll's like the ones made in C++ are compiled down into machine code. machine code is ASM. C# dll's are compiled down to MSIL (I belive that is it). than when you run the dll or exe the .net CLR takes the MSIL and compiles it down to Machine Code. but the problem is the CLR doesn't compile the whole thing, it is inteligent. those are the reasons it doesn't work. you can call native from managed but not managed from native"...

and i just wanted to know if it'd work before i take the time to write a class library...

i did a quick test and does'nt seem to work...

c# code:

using System;
using System.IO;
namespace ClassLibrary3
{
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    public class Class1
    {
        public Class1()
        {
        
        }

        public void fwrite()
        {
            FileStream fs = new FileStream("file.txt", System.IO.FileMode.Open);
            StreamWriter sw = new StreamWriter("file.txt");
            sw.Write("test");
            sw.Close();
            fs.Close();
        }
    }
}

auto it code:

DllCall("test.dll", "none", "fwrite")

* I know someone wrote a C# dll and used it for some console functions im sure, but could'nt find that thread...

Edited by CHRIS95219
Link to comment
Share on other sites

Your friend is right, but he's also jumping the gun a little...

C# dll are compiled to MSIL only using the microsoft compiler (like in visual studio)

You need a different compiler (look at ngen at http://msdn2.microsoft.com/en-us/library/6t9t5wcf.aspx) to compile it into machine code like your friend said.

Edit: posted link wrong

Edited by evilertoaster
Link to comment
Share on other sites

I'm quite shure I have seen tools to make stub dll's to make calls to a C# "dll" possible. But there are probably a lot of constraints on what your aloved to do. I also think you would be better of using a COM dll and the COM interface/methodes in AutoIt.

Link to comment
Share on other sites

Your friend is right, but he's also jumping the gun a little...

C# dll are compiled to MSIL only using the microsoft compiler (like in visual studio)

You need a different compiler (look at ngen at http://msdn2.microsoft.com/en-us/library/6t9t5wcf.aspx) to compile it into machine code like your friend said.

ah. That sounds more reasonable. Thanks.

ulten > Im not sure how to write a COM dll.. I've searched for tutorials but can't seem to find any..

Edited by CHRIS95219
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...