It's called P/Invoke and uses
System.Runtime.InteropServices
and
System.Runtime.InteropServices.DllImportAttribute
.
You can find a simple code sample here:
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx[
^].
It may me fairly simple or quite tricky. To specify marshaling between native (unmanaged) and managed parameters you may also need to use the attribute
System.Runtime.InteropServices.MarshalAsAttribute
, see the code sample:
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute.aspx[
^].
In more complex cases (in particular, when memory allocation is involved), you may need to use explicit marshaling methods with the class
System.Runtime.InteropServices.Marshal
, see
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.aspx[
^].
In even more complex cases you may need to use
custom marshaling. See, for example:
http://msdn.microsoft.com/en-us/magazine/cc164085.aspx[
^].
[EDIT]
After changes in Microsoft documentation, most adequate link to P/Invoke and C++/CLI
implicit P/Invoke is this:
https://msdn.microsoft.com/en-us/library/ms235282.aspx[
^].
—SA