指向整体式和背面的指针 [英] Pointer to integral type and back
问题描述
我需要将指向对象的指针转换为整数类型并将其传递给C#模块,然后C#模块将其异步传递回C ++模块。我不能只将这个指针存储到我的C ++模块中的对象中,并在稍后的回调点使用它作为参考
,这是排除的。我需要将它传递给C#并将其恢复到我的回调函数中。
$
此链接:
https:// msdn .microsoft.com / zh-CN / library / windows / desktop / aa384242(v = vs.85).aspx
建议使用UINT_PTR或INT_PTR进行转换,但如何将此类型传递给C# 。可以传递为long还是double?
$
此外,当C#模块将其传回long或double时,如何将其转换回指针类型?
$ T $,
Jy
I have a need to convert a pointer to an object to an integral type and pass it to a C# module, which in turn passes it back to the C++ module asynchronously. I cannot just store this pointer to object in my C++ module and use it for reference
later at the point of callback, that is ruled out. I need to pass it to C# and get it back in my callback function.
This link:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa384242(v=vs.85).aspx
suggests using UINT_PTR or INT_PTR to convert, but how do I pass this type to C#. Can it be passed as long or double?
Also, when the C# module passes it back as long or double, how do I convert it back to a pointer type?
TIA,
Jy
推荐答案
我认为
IntPtr 结构可用于存储指针。在C#参数的声明中使用 IntPtr ,在本机C ++中使用
INT_PTR 。显示模块之间交互的一些细节。
I think that the IntPtr structure can be used to store pointers. Use IntPtr in the declaration of C# parameters, and INT_PTR in native C++. Show some details about the interaction between modules.
这篇关于指向整体式和背面的指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!