How to use LIB file in C# project?

c#, c++, static-libraries, visual-studio-2010

Solution

You can create a DLL where you create a wrapper function for each function from the .lib:

extern "C" __declspec (dllexport) HANDLE OpenFile(char const * filename)
{
    return open_file(filename);
}

In C# you use P/Invoke to make the dll function available:

[DllImport("WrapperLib.dll")]
private static extern System.IntPtr OpenFile(string filename);

Problem

There is a `lib` file along with `.h`, which is working with some device driver. A sample Visual Studio C++ project is using that library as static linked. There are only 2 functions exported from that library. ``` HANDLE open_dev(); HANDLE open_file( char *filename ); ``` I want to use that library in my C# project and again static link it. How it's possible?

Original source