HIDAPI - using in a c# project

1.3k views Asked by At

A high level question about HIDAPI, if anyone has any experience with it - http://www.signal11.us/oss/hidapi/ - The visual studio solution is written in C++, and I have a C# project that I want to use the library on. Is there any way to use the C++ library? Can I build a DLL from the solution and add it as a reference on my C# project?

1

There are 1 answers

0
durkmurder On

From what I see HIDAPI is a C library, not C++. It contains only structures and functions. Theoreticaly you can go on with DLLImport + PINVOKE, but it can be very annoying and troublesome to map C structures to C# types. I would suggest to create a C++/CLI class which will have "high-level" interface and will use HIDAPI as backend. All the logic will be hidden in C++/CLI class and user will only use high-level functions. In that case you will get a managed dll which you will be able to use in your C# project with ease. Hope that will help you.