G
_Gabriel_
Guest
Im implementing an IDropTarget COM interface which allow any OLE application to drag system paths (physical or virtual) over my application.
The code works fine when I drop folders and files from desktop or Windows Explorer, but fails when I drop a menu item from Windows 10 Start Menu.
The code fails in IDataObject::QueryGetData using CFSTR_SHELLIDLIST clipboard format. I mean the line:
Dim COM_CODE as Integer = DataObj.QueryGetData(format)
- Returns S_OK for files and folders
- Returns DV_E_LINDEX (COM ERROR CODE = 0x80040068) for Windows 10 Start menu elements.
More information:
- The debugger tells me that the value of RegisterClipboardFormat(CFSTR_SHELLIDLIST) is 49406
By using IDataObject::EnumFormatEtc I got the following formats:
Physical Path: 49406, 49994, ...
Virtual Path: 49406, 49417, ...
Start menu item: 49406, 49417, ...
which it shows that a Start menu item contains the CFSTR_SHELLIDLIST format but using iDataObject::QueryGetData says no.
Here is the relevant code:
_format = RegisterClipboardFormat(CFSTR_SHELLIDLIST)
Public Function DragDrop1(ByVal pDataObj As System.IntPtr, ByVal grfKeyState As Integer, ByVal pt As ShellCOM._POINT, ByRef pdwEffect As Integer) As Integer Implements ShellCOM.IDropTarget.DragDrop
Dim DataObj As ShellCOM.IDataObject
DataObj = Marshal.GetTypedObjectForIUnknown(pDataObj, GetType(ShellCOM.IDataObject))
If DataObj IsNot Nothing Then
Dim format As New FORMATETC
Dim medium As New STGMEDIUM
format.cfFormat = _format
format.ptd = 0
format.dwAspect = DVASPECT.DVASPECT_CONTENT
format.lindex = 0
format.Tymed = TYMED.TYMED_HGLOBAL
If DataObj.QueryGetData(format) = S_OK Then <----- code fail here, what is the correct format for an element from Windows 10 Start Menu?
....
....
End If
End If
Return S_OK
End Function
Continue reading...
The code works fine when I drop folders and files from desktop or Windows Explorer, but fails when I drop a menu item from Windows 10 Start Menu.
The code fails in IDataObject::QueryGetData using CFSTR_SHELLIDLIST clipboard format. I mean the line:
Dim COM_CODE as Integer = DataObj.QueryGetData(format)
- Returns S_OK for files and folders
- Returns DV_E_LINDEX (COM ERROR CODE = 0x80040068) for Windows 10 Start menu elements.
More information:
- The debugger tells me that the value of RegisterClipboardFormat(CFSTR_SHELLIDLIST) is 49406
By using IDataObject::EnumFormatEtc I got the following formats:
Physical Path: 49406, 49994, ...
Virtual Path: 49406, 49417, ...
Start menu item: 49406, 49417, ...
which it shows that a Start menu item contains the CFSTR_SHELLIDLIST format but using iDataObject::QueryGetData says no.
Here is the relevant code:
_format = RegisterClipboardFormat(CFSTR_SHELLIDLIST)
Public Function DragDrop1(ByVal pDataObj As System.IntPtr, ByVal grfKeyState As Integer, ByVal pt As ShellCOM._POINT, ByRef pdwEffect As Integer) As Integer Implements ShellCOM.IDropTarget.DragDrop
Dim DataObj As ShellCOM.IDataObject
DataObj = Marshal.GetTypedObjectForIUnknown(pDataObj, GetType(ShellCOM.IDataObject))
If DataObj IsNot Nothing Then
Dim format As New FORMATETC
Dim medium As New STGMEDIUM
format.cfFormat = _format
format.ptd = 0
format.dwAspect = DVASPECT.DVASPECT_CONTENT
format.lindex = 0
format.Tymed = TYMED.TYMED_HGLOBAL
If DataObj.QueryGetData(format) = S_OK Then <----- code fail here, what is the correct format for an element from Windows 10 Start Menu?
....
....
End If
End If
Return S_OK
End Function
Continue reading...