I need help to create an IDataObject to enable drag and drop of these 2 Items (Run and Help) For Example I need to do just like Windows Startmenu does.
to run them I use these
CComPtr<IShellDispatch2> pShellDisp;
if (SUCCEEDED(CoCreateInstance(CLSID_Shell,NULL,CLSCTX_SERVER,IID_IShellDispatch2,(void**)&pShellDisp)))
{
pShellDisp->Help(); //Help
pShellDisp->FileRun(); //Run
}
Can you guys help me out ?
PS: I need the drag with image Icons too
EDIT [SOLVED]
IShellFolder* desk = NULL;
HRESULT hr =SHGetDesktopFolder(&desk);
LPITEMIDLIST pidl2=NULL;
ULONG cbEaten;
DWORD dwAttribs = 0 ;
hr = desk->ParseDisplayName(NULL,
NULL,
L"shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}",
&cbEaten, // This can be NULL
&pidl2,
&dwAttribs);
hr = desk->GetUIObjectOf(parentHwnd, 1,
(PCITEMID_CHILD*)&pidl2, IID_IDataObject, 0, (LPVOID *)lpdataObj);
desk->Release();
return;
for run:
shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}
I assume you only want one of those items in the data object at any point in time, in that case:
IShellItem::BindToHandler(...,BHID_DataObject,...)
.If you want to drag&drop both items in the same operation then things get hard. I don't know if both of those objects have the same parent. If they do then even the old CIDLData_CreateFromIDArray can handle it. If they don't then you could try SHCreateShellItemArrayFromIDLists and then use
IShellItemArray::BindToHandler(...,BHID_DataObject,...)
. To support < Vista I believe you have to create your own CFSTR_SHELLIDLIST and add it to the dataobject.Drag images are not really related to this and should be asked in a separate question where you include information about your IDragSourceHelper etc.