如何将pinned_ptr复制到托管?
ManagedClass^ managed = gcnew ManagedClass();
array<unsigned char>^ temp = .....
pin_ptr<unsigned char> pinned_ptr = &temp[0];
//I TRIED THESE WAYS TO COPY:
memcpy(managed, pinned_ptr, sizeof(managed)); //ManagedStructure^ is incompatible parameter w,th void*
memcpy((void*)managed, pinned_ptr, sizeof(managed)); //invalid type conversion
memcpy((void*)&managed, pinned_ptr, sizeof(managed)); //invalid type conversion
然后,我尝试使用Marshal :: Copy那样:
Marshal::Copy(IntPtr((void*)managed), pinned_ptr, 0, sizeof(managed)); //no insatance of overloaded function Marshal::Copy
//parameters list (System::IntPtr, cli::pin_ptr<unsigned char>,int, unsigned int)