"Mark Salsbery [MVP]" <MarkSalsbery[MVP]@newsgroup.nospam> wrote in message
news:BD264A84-
> You can use System::Runtime::InteropServices::Marshal::Copy(), which does the
> "loop through it copying " part for you
I've tried several variations on the following code, but it complains that it
can't find an overload for Marshal::Copy that it likes. I suspect that it
doesn't like the boxed handle to an IntPtr that I think I'm trying to feed it
(by way of the gcnew IntPtr() code). How do I cast a char* to an IntPtr?
const char* value = <some array of bytes>
int size = 15;
array<unsigned char>^ myArray = gcnew array<unsigned char>(size);
Marshal::Copy(gcnew IntPtr((void*)value), myArray, 0, size);