1

I have some c headers, and a c lib that I'd like to import and use in a c# project. How can I do this?

Mehrdad Afshari
  • 414,610
  • 91
  • 852
  • 789
Malfist
  • 31,179
  • 61
  • 182
  • 269

2 Answers2

4

Use [System.Runtime.InteropServices.DllImport] attribute (P/Invoke):

[DllImport("dllname.dll")]
static extern void MyFunctionName();
Mehrdad Afshari
  • 414,610
  • 91
  • 852
  • 789
2

What Mehrdad said.

Additionally, welcome to the wonderful world of marshalling. P/Invoke.Net is your new best friend.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794