将C#转换为C ++以转换IntPtr [英] Casting C# into C++ to cast IntPtr

查看:84
本文介绍了将C#转换为C ++以转换IntPtr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试将几行C#代码转换为C ++.
m在使用时遇到问题

Hi,
I m trying to cast few lines of c# code into c++.
m having problem in using

private IntPtr m_hContext = IntPtr.Zero;
IntPtr hContext = Marshal.AllocHGlobal(Marshal.SizeOf(m_hContext));
m_hContext = Marshal.ReadIntPtr(hContext);
Marshal.FreeHGlobal(hContext);


我无法在c ++中找到它的等效项.帮帮我..


I m unabgle to find its equivalence in c++... Help me out..

推荐答案

Hellexx,
也许会对您有所帮助: http://tangiblesoftwaresolutions.com/Product_Details/CSharp_to_CPlusPlus_Converter_Details.html
您可以使用从C ++到C#转换器的演示版进行一次最多2000行的文件夹转换和一次最多200行的代码段转换.
Hi Hellexx,
maybe it will help you : http://tangiblesoftwaresolutions.com/Product_Details/CSharp_to_CPlusPlus_Converter_Details.html
You can use the Demo Edition of C++ to C# Converter for folder conversions up to 2000 lines and code snippet conversions up to 200 lines at a time.


您是否尝试过GlobalAlloc()或GlobalHandle ()?
do you have tried GlobalAlloc() or GlobalHandle()?


IntPtr可以引用C ++的常规指针,无论它是什么:void *,int *,long *,float *,等等.
如果您要调用返回指针的C ++函数或需要引用的指针参数,请

您肯定像您编写的那样在C#代码中需要IntPtr.
IntPtr can refer to a conventional pointer of C++, whatever it is : void*, int*, long*, float*, so on.

If you are gonna call a C++ function which returns a pointer or need a referenced pointer parameter,

you surely needs IntPtr in your C# code like you wrote.


这篇关于将C#转换为C ++以转换IntPtr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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