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.
I m trying to use some legacy Delphi 5 DLLs from C# (2.0/3.5). Some of the exported functions are declared as such: function SimpleExport: OleVariant; stdcall; function BiDirectionalExport(X: ...
I have a DLL that I need to P/Invoke the following method: DWORD Foo( int a, int *b, char *c ); Per the documentation, parameter c is an out parameter that must be a ...
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 ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
First of all the Boolean type is said to have a default marshal type of a four-byte value. So the following code works: struct A { public bool bValue1; public int iValue2; ...
I have to use a legacy C routine in the application I am developing. The code in here works, but I have to convert almost all the fields to char arrays in order to use it. There is a better way to do ...
I have a C# application that uses the SendMessage pinvoke method to send a "close window" message (WM_CLOSE / 16) to various windows outside the application. This works great, except when the window ...
Is there a managed API for kernel32.searchpath? i.e not using a pinvoke. http://www.pinvoke.net/default.aspx/kernel32.searchpath