显式/隐含P / Invoke概念 [英] Explicit/Implicit P/Invoke concept

查看:77
本文介绍了显式/隐含P / Invoke概念的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不熟悉托管< - >的平台调用非托管代码互操作。



在阅读了一些文档之后,我发现当托管代码调用非托管(本机)代码时,只应用P / Invoke。是对的吗?



非托管代码调用托管dll怎么样?

我找到了一个名为将托管组件暴露给COM的有趣方法,可以应用于非托管代码调用托管组件(因此它不是P / Invoke的一部分?)

I'm new to platform invoke for managed <-> unmanaged code interop.

After reading some documents, I found P/Invoke is ONLY applied when managed code to call unmanaged(native) code. Is that right?

How about unmanaged code calls managed dll?
I find an interesting approach called "exposing managed component to COM" which can be applied when unmanaged code calls managed component(so it is not part of P/Invoke?)

推荐答案

平台调用用于从托管代码调用Win32函数。

请参见 PInvoke.net/ [ ^ ]



从非托管代码调用托管代码一种方法是使用COM Interop导出COM接口来自托管代码。

请参阅 COM Interop Part 2 [ ^ ]



所以是的,你的假设是正确的。
Platform Invoke is used to call Win32 functions from managed code.
See PInvoke.net/[^]

For calling managed code from unmanaged code one approach is to use COM Interop where COM interfaces are exported from the managed code.
See COM Interop Part 2[^]

So yes, you are right in your assumptions.


这篇关于显式/隐含P / Invoke概念的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆