English 中文(简体)
How does the .NET Framework Class call Platform API?
原标题:

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:

  1. Through P/Invoke
  2. VC++/CLI
  3. Both 1 and 2

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.

问题回答

暂无回答




相关问题
Marshaling Delphi 5 OleVariant to C#

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: ...

P/Invoke for pointer to array of char

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 ...

How does the .NET Framework Class call Platform API?

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 ...

C# Marshal / Pinvoke CBitmap?

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 ...

How should I declare this C struct for interop?

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 ...

热门标签