Eabin
July 21st, 1999, 11:37 AM
As you (may) remember, I asked if anyone knows how to start the primary application,
given an IShellFolder - Object and relative to this an ITEMIDLIST, as the explorer
does if user double - clicks left.
Well, nobody answered and i found the following solution:
It is not very elegant, but fast and it works:
//given Objects
IShellFolder* parentFolder;
ITEMIDLIST *IIDList;
void LaunchObject(IShellFolder* parentFolder, ITEMIDLIST *IIDList)
{
HRESULT hres;
IContextMenu* ICtx;
DWORD stdCommand;
UINT reserved;
CMINVOKECOMMANDINFO ICInfo;
HMENU myMenu;
hres = parentFolder->GetUIObjectOf(NULL, 1, &IIDList,
IID_IContextMenu, &reserved,
(void**)&ICtx);
if (SUCCEEDED(hres))
{
myMenu = CreatePopupMenu();
hres=ICtx->QueryContextMenu(myMenu, 0,0, 10000, CMF_NORMAL);
stdCommand = GetMenuItemID(myMenu, 0); //this will be the default
DestroyMenu(myMenu);
ICInfo.cbSize = sizeof(ICInfo);
ICInfo.fMask = 0;
ICInfo.hwnd = NULL;
ICInfo.lpParameters = Params;
ICInfo.lpDirectory = NULL;
ICInfo.nShow = SW_NORMAL;
ICInfo.lpVerb = (const char*) (stdCommand);
hres=ICtx->InvokeCommand(&ICInfo);
ICtx->Release();
}
}
well, that's all.
if somebody is interested in full source code, please mail to Eabin@yline.com
given an IShellFolder - Object and relative to this an ITEMIDLIST, as the explorer
does if user double - clicks left.
Well, nobody answered and i found the following solution:
It is not very elegant, but fast and it works:
//given Objects
IShellFolder* parentFolder;
ITEMIDLIST *IIDList;
void LaunchObject(IShellFolder* parentFolder, ITEMIDLIST *IIDList)
{
HRESULT hres;
IContextMenu* ICtx;
DWORD stdCommand;
UINT reserved;
CMINVOKECOMMANDINFO ICInfo;
HMENU myMenu;
hres = parentFolder->GetUIObjectOf(NULL, 1, &IIDList,
IID_IContextMenu, &reserved,
(void**)&ICtx);
if (SUCCEEDED(hres))
{
myMenu = CreatePopupMenu();
hres=ICtx->QueryContextMenu(myMenu, 0,0, 10000, CMF_NORMAL);
stdCommand = GetMenuItemID(myMenu, 0); //this will be the default
DestroyMenu(myMenu);
ICInfo.cbSize = sizeof(ICInfo);
ICInfo.fMask = 0;
ICInfo.hwnd = NULL;
ICInfo.lpParameters = Params;
ICInfo.lpDirectory = NULL;
ICInfo.nShow = SW_NORMAL;
ICInfo.lpVerb = (const char*) (stdCommand);
hres=ICtx->InvokeCommand(&ICInfo);
ICtx->Release();
}
}
well, that's all.
if somebody is interested in full source code, please mail to Eabin@yline.com