如何将c ++ dll中的BYTE *传递给c# [英] how to pass BYTE* in c++ dll to 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屋!