M
Marauderz
Hi there,
Got a quick question, I have an app that I'm compiling with /clr and I have
a native function that passes in a pointer, and I need to copy from that
unmanaged memory into a managed Byte array but I can't quite figure out how
to properly cast everything, here's what I have right now.
static void CopyData(const void* buf, int size)
{
System::IntPtr^ ptrBuf=gcnew System::IntPtr((int)buf);
array<System::Byte>^ MyBuf=gcnew array<Byte>(size);
System::Runtime::InteropServices::Marshal::Copy(ptrBuf,(array<unsigned
char>^)MyBuf,0,size);
}
I'm getting an error that's saying none of the 16 overloads could convert
all the argument types.
So I'm guessing I am most likely not casting the destination buffer to a
correct type? I've already tried using Byte for my array but alas my weak
C++ skills just ain't helping.. Can anyone tell me where I'm going wrong?
Got a quick question, I have an app that I'm compiling with /clr and I have
a native function that passes in a pointer, and I need to copy from that
unmanaged memory into a managed Byte array but I can't quite figure out how
to properly cast everything, here's what I have right now.
static void CopyData(const void* buf, int size)
{
System::IntPtr^ ptrBuf=gcnew System::IntPtr((int)buf);
array<System::Byte>^ MyBuf=gcnew array<Byte>(size);
System::Runtime::InteropServices::Marshal::Copy(ptrBuf,(array<unsigned
char>^)MyBuf,0,size);
}
I'm getting an error that's saying none of the 16 overloads could convert
all the argument types.
So I'm guessing I am most likely not casting the destination buffer to a
correct type? I've already tried using Byte for my array but alas my weak
C++ skills just ain't helping.. Can anyone tell me where I'm going wrong?