How can I use a DLL written in C

0

I'm a little new with this library management.

It turns out that I need to use the GNU Libmicrohttpd library found on this link link .

This library the inconvenience that I have found is that it is written in C and the project that I am doing is in .Net and when trying to add the dll in Visual studio I get the following error:

What chance can I have to add it to the project? I appreciate your collaboration

    
asked by araad1992 16.08.2017 в 17:37
source

1 answer

0

The first thing you need to know is if this library is compiled in "windows" mode, if so you can use PINVOKES to be able to call the library.

In this link you will see a full tutorial on how to do it.

Even so, a brief summary is that you will have to define the functions that you need to invoke from your code with DLLIMPORT defining an intermediary function to invoke the one from the library.

It would be something like this:

public class TestPInvoke
{
    [DllImport("user32.dll")]
    public static extern int MessageBoxA(int h, string m, string c, int type);

    public static void Main() 
    {
        MessageBoxA(0, "Buenas!", "mensaje desde windows", 0);
    }
}
    
answered by 17.08.2017 в 07:48