Using .NET Routines in Win32 Code

The CLR offers support for the opposite of what Platform Invoke offers, which is to expose .NET static methods to the unmanaged Win32 world. These are often referred to as unmanaged exports. Unmanaged exports are implemented by the CLR using the exact inverse of its P/Invoke mechanism which is why the support is sometimes referred to as Inverse P/Invoke.

A Win32 application can import these exposed routines in the same way as with any regular DLL exported routines. The support for this CLR feature is not taken advantage of by many languages; only Managed C++ and Delphi for .NET support it directly as a language feature. In Delphi’s case, it is limited to exporting global functions, which internally are implemented ...

Get Delphi for .NET Developer’s Guide 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.