void *到C ++ / CLI中的Object ^ [英] void* to Object^ in C++/CLI

查看:552
本文介绍了void *到C ++ / CLI中的Object ^的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力将大量的.h和.lib文件从本机C ++包装到托管C ++,最终用作C#中引用的.dll。

I am working on wrapping a large number of .h and .lib files from native C++ to Managed C++ for eventual use as a referenced .dll in C#.

一些本机C ++函数的返回类型为void *。我不知道如何处理这个当我将值传递回我的调用代码。例如:如果一个C#应用程序调用我的dll包装,我从本地调用返回:

Some of the native C++ functions have a return type of void*. I am not sure how to handle this when I pass back the value to my calling code. For instance: if a C# app calls my dll wrapper, what do I return from the native call:

void* start(ThreadFunc,void *, unsigned *);

我目前正试图在通用System :: Object ^这是包装器中的调用:

I am currently attempting to box the return in a generic System::Object^ with no luck. This is the call in the wrapper:

m_NativeThread->start(cb, 
        GCHandle::ToIntPtr(GCHandle::Alloc(o)).ToPointer(),
        static_cast<unsigned int*>(GCHandle::ToIntPtr(GCHandle::Alloc(u)).ToPointer())));

任何人都可以提供解决方案?

Can anyone offer a solution?

推荐答案

你能使它成为一个IntPtr吗?你期望客户对void *做什么?

Can you make it an IntPtr? What do you expect the client to do with the void*?

这篇关于void *到C ++ / CLI中的Object ^的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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