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?
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With