The PInvoke Utility
Apart from COM interoperability, .NET applications might also have to access some of the functions existing in the Win32 API or in other unmanaged DLLs. An unmanaged DLL is one created using unmanaged code. For example, a DLL created using Visual Basic 6 is an unmanaged DLL. Functions that exist in unmanaged DLLs are unmanaged functions. In order to access these unmanaged functions, the .NET Framework provides the Platform Invocation Services, also referred to as PInvoke.
PInvoke handles the tasks of finding and invoking the correct function from the DLL. It also handles the marshalling between the managed .NET application and the unmanaged DLL function.
Unsafe and Unmanaged Code
To understand the use of PInvoke, take a ...
Get Special Edition Using C# now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.