将Object转换为IntPtr [英] Convert Object to IntPtr
本文介绍了将Object转换为IntPtr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
有没有办法在Cpp代码中将System.Object转换为IntPtr或char *。
谢谢
解决方案
看看这些链接:
http:/ /msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.structuretoptr%28VS.71%29.aspx [ ^ ]
http: //msdn.microsoft.com/en-us/library/system.runtime.interopservices.gchandle%28v=VS.71%29.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/aa719791%28v=VS.71%29.aspx [ ^ ]
在我做任何评论之前,我想请你提供一些关于你想要实现的目标?的描述。 br />
因为,如果要将值分配给来自不同类型的任何变量,那么有时不使用类型转换或转换,简单的内存副本也可以这样做。 / blockquote>
我使用 GetIUknownForObject解决了这个问题 [ ^ ]然后 GetObjectForIUknown [ ^ ]。
Hello
Is there any way to convert System.Object to IntPtr or char* in cpp code.
Thanks解决方案Have a look at these links:
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.structuretoptr%28VS.71%29.aspx[^]
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.gchandle%28v=VS.71%29.aspx[^]
http://msdn.microsoft.com/en-us/library/aa719791%28v=VS.71%29.aspx[^]
Good luck!
Before I made any comment, I would rather like to ask you to provide a bit description about - "What you are trying to achieve?"
Because, if you want to assign value into any variable from a different type, then sometime with out type casting or converting, a simple memory copy can do the same.
I solved this by using GetIUknownForObject[^] and then GetObjectForIUknown[^].
这篇关于将Object转换为IntPtr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文