We know that .NET framework class encapsulate the Win32 API, now I am wondering how the .NET framework class call Win32 API?
Ways I know so far:
- Through P/Invoke
- VC++/CLI
- Both 1 and 2
Anybody know the answer?
We know that .NET framework class encapsulate the Win32 API, now I am wondering how the .NET framework class call Win32 API?
Ways I know so far:
Anybody know the answer?
Most framework classes use P/Invoke if they need to call unmanaged APIs. Fire up Reflector on System.Windows.Forms and you'll see classes called NativeMethods and UnsafeNativeMethods which do a lot of P/Invoke. Similarly System.Drawing has a SafeNativeMethods class which declares all the GDI+ P/Invokes.
The other main interop method you don't mention is COM interop. I don't know how widely this is used within the framework, but I'd guess that some of the WMI (System.Management) stuff uses it pretty heavily, plus of course WinForms ActiveX support.