3. Platform Invoke

In this chapter, we discuss Platform Invoke, a .NET feature for calling functions in native Win32 DLLs from managed code.

THIS CHAPTER COVERS Platform Invoke—also known as P/Invoke—a .NET feature for calling functions in native dynamic link libraries (DLLs). Most of the time the .NET Compact Framework provides all the support you need to build programs. Sometimes you need something that is not supported by the .NET Compact Framework but is supported by calling a function in a Win32 DLL. For such cases, there is P/Invoke.

To call a function in a native DLL from managed code, you create a P/Invoke wrapper. A P/Invoke wrapper looks just like a managed-code method declaration. One difference is that a P/Invoke wrapper lacks a ...

Get Programming .NET Compact Framework 3.5 Second Edition 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.