| Start |
|---|
Calling a Win32 dll function Declare a function as The Platform Invocation Services will take care of loading the .dll and finding the desired finction. The P/Invoke in most simple cases will also marshal parameters and return value to and from the .dll (i.e. convert from .NET datatypes to Win32 ones and vice versa). |
| Using Windows API Use pinvoke.net (opens new window). Before declaring an |
| Marshalling arrays Arrays of simple type Arrays of string |
| Marshaling structs Simple struct C++ signature: C# definition Struct with unknown size array fields. Passing in C++ signature When passed from managed to unmanaged code, this The Struct with unknown size array fields. Receiving C++ signature: When such data is passed out of unmanaged code and memory is allocated by the unmanaged functions, the managed caller should receive it into an |
| Marshaling unions Value-type fields only C++ declaration C# declaration Mixing value-type and reference fields Overlapping a reference value with a value type one is not allowed so you cannot simply use the and generally you would have to employ custom marshaling. However, in particular cases like this simpler technics may be used: Syntax |
Read Article
https://develop.horje.com/learn/1434/reference