我正在尝试通过c ++从C#调用C语言中的函数
所以基本上就是C# -> C++ - >C
在C#中,我有byte[]字节-它从文件中读取信息。我将字节数组和大小传递给C++。
在C++中,我可以获得字节数组和大小,但不能转换为特定的数据类型。
void Image::OpenMemFile(array<Byte>^ data, unsigned int size)
{
Free();
m_dataStream = data;
Byte const* streamData = &data[0]; // this is where it throws error
// Should I use marshaling here ? What call should that ;be ?
hImage = ::OpenMemImage(streamData , size);
modified = false;
}
// this is the function I need to call
EXIVSIMPLE_API HIMAGE OpenMemImage(const BYTE *data, unsigned int size)
{
// code
imgWrap->image = Exiv2::ImageFactory::open(data, size);
}它需要调用的C函数是
Image::AutoPtr ImageFactory::open(const byte* data, long size)
{
/// code
}我需要帮助将字节数组转换为const byte*。我意识到我需要使用封送处理。在C++中有一个特定的函数来封送数组吗?
任何帮助都是非常感谢的。
谢谢
发布于 2010-10-19 23:09:33
pin_ptr<unsigned char> pin_buffer = &data[0];
unsigned char* pData = pin_buffer;https://stackoverflow.com/questions/2194413
复制相似问题