问题
I'm trying to use this excellent example to implement dropping virtual files into Windows Explorer. However, I'm stymied by this error. Towards the bottom, inside void System.Runtime.InteropServices.ComTypes.IDataObject.GetData(ref System.Runtime.InteropServices.ComTypes.FORMATETC formatetc, out System.Runtime.InteropServices.ComTypes.STGMEDIUM medium)
on the first call to ((System.Runtime.InteropServices.ComTypes.IDataObject)this).GetDataHere(ref formatetc, ref medium);
I'm getting back a DV_E_FORMATETC
error. As far as I can tell, all the elements of the FORMATETC struct that are being passed in are valid: cfFormat is "Shell IDList Array" (-16141), ptd is 0, dwAspect is DVASPECT_CONTENT, lindex is -1, and tymed is TYMED_HGLOBAL. I'm kind of confused how there'd be a problem anyway, since this was generated by explorer.
I know very little about COM interaction, so any help would be greatly appreciated.
回答1:
After reimplementing about half of IDataObject, it turns out that error code is caused by not supporting "Shell IDList Array" in GetDataPresent().
来源:https://stackoverflow.com/questions/2917988/drag-and-drop-to-explorer-causing-invalid-formatetc-dv-e-formatetc-error