如何将c ++ dll中的BYTE *传递给c# [英] how to pass BYTE* in c++ dll to c#

查看:311
本文介绍了如何将c ++ dll中的BYTE *传递给c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道  BYTE的长度*  ,在c ++函数执行之前。

I dont know the  length of BYTE*  ,before c++ function execute.

c ++函数:

extern "C" _declspec(dllexport) void GetImage(uint64_t* sourceRoiSize, BYTE* ptrDataRoi)
{
memcpy(ptrDataRoi, (BYTE*)bitmapData.ptrDataRoi, bitmapData.size);
}

c#function:

c# function:

  [DllImport(@"Conver.dll", EntryPoint = "GetImage", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        public static extern void GetImage(ref ulong sourceRoiSize, ref byte ptrDataRoi);


byte[] ptrDataRoi = new byte[length];
long sourceRoiSize=0;
GetImage(ref sourceRoiSize,ptrDataRoi[0]);




我现在使用上面的方法来获取这个数组。但长度是猜测。如果我使用system.intptr,我无法得到它。那我怎么得到这个数组?


I now use the above method to get this array. But length is a guess. If I use system.intptr, I can't get it. So how do I get this array?

推荐答案

你需要阅读文档libCZI。它会回答这样的问题。你需要帮助吗?你找到了C#样本吗?您从蔡司显微镜开发者社区获得了什么回应?

You need to read the documentation of libCZI. It will answer questions like that. Do you need help with that? Did you find the C# sample? What response did you get from the ZEISS Microscopy Developer Community?

为了其他人的利益,请参阅
如何将C ++ dll中的CImage或IWICStream或Image传递给c#

For the benefit of others, see How to pass a CImage or IWICStream or Image in c++ dll to c#.


这篇关于如何将c ++ dll中的BYTE *传递给c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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