P/Invoke

简介:

Platform Invocation Services, commonly referred to as P/Invoke, is a feature of Common Language Infrastructure implementations, like Microsoft's Common Language Runtime, that enables managed code to call native code.

 

When using P/Invoke, the CLR handles DLL loading and conversion of the unmanaged previous types to CTS types (also referred to as parameter marshalling)[1]. To perform this, the CLR:

  • Locates the DLL containing the function.
  • Loads the DLL into memory.
  • Locates the address of the function in memory and pushes its arguments onto the stack, marshaling data as required.

P/Invoke is useful for using standard (unmanaged) C or C++ DLLs. It can be used when a programmer needs to have access to the extensive Windows API, as many functions provided by the Windows libraries lack available wrappers. When a Win32 API is not exposed by the .NET framework the wrapper to this API must be written manually.





















本文转自cnn23711151CTO博客,原文链接:http://blog.51cto.com/cnn237111/526932 ,如需转载请自行联系原作者










相关文章
|
6月前
|
Java 测试技术
Java反射之Method的invoke方法详解
Java反射之Method的invoke方法详解
|
7月前
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘quanZiController‘ method
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘quanZiController‘ method
54 0
|
Java
Java反射(Method)(三)
日常开发中,我们可使用反射获取JavaBean的方法信息,而描述属性信息的就是Java Method,Method类同样位于java.lang.reflect包下。
187 0
Java反射(Method)(三)
|
安全 iOS开发
Method Swizzling
Method Swizzling
210 0
Method Swizzling
Caused by: java.lang.NoSuchMethodError:No virtual method isSuccess()Z in class Lretrofit2/Response;
Caused by: java.lang.NoSuchMethodError:No virtual method isSuccess()Z in class Lretrofit2/Response;
1242 0
|
缓存 安全 Java
Java反射包下的Method类中的Invoke方法
Java反射包下的Method类中的Invoke方法
170 0
Java反射包下的Method类中的Invoke方法
|
Java 程序员
Java 方法method
Java 方法method
129 0
Java 方法method
|
消息中间件 API Windows