为什么P/Invoke函数必须在C#中是静态的?

Dot*_*Dot -1 c#

看代码:

class VirtualMemoryManager
{
    [DllImport("kernel32.dll",EntryPoint="GetCurrentProcess")]
    internal static extern IntPtr GetCurrentProcessHandle();
}
Run Code Online (Sandbox Code Playgroud)

为什么"GetCurrentProcessHandle"必须"静态"

use*_*702 6

这是P/Invoke方法的要求,因为Windows API中没有一致的实例概念.

来源:http://msdn.microsoft.com/en-us/magazine/cc164123.aspx