I’m trying to convert System::Windows::Forms::IDataObject into the native IDataObject defined in the ObjIdl.h. Unfortunately the following source code doesn’t return the native IDataObject.
IntPtr pData = System::Runtime::InteropServices::Marshal::GetIUnknownForObject(e->Data);
::IDataObject* data = (::IDataObject*) pData.ToPointer();
How can I get the native IDataObject in a Windows Forms application during Drag and Drop?
Casting a COM interface pointer with a C-style cast is not legal. You have to ask nicely with the QueryInterface() method. Like this: