@@ -322,6 +322,9 @@ static void AddJumpItem( CJumpGroup &group, IUnknown *pUnknown, std::vector<CCom
322
322
}
323
323
}
324
324
LOG_MENU (LOG_OPEN,L" Jumplist Link Name: %s" ,item.name );
325
+ #ifdef _DEBUG
326
+ LogPropertyStore (LOG_OPEN, pStore);
327
+ #endif
325
328
if (!item.name .IsEmpty ())
326
329
group.items .push_back (item);
327
330
return ;
@@ -519,91 +522,15 @@ bool GetJumplist( const wchar_t *appid, CJumpList &list, int maxCount, int maxHe
519
522
bool ExecuteJumpItem ( const CItemManager::ItemInfo *pAppInfo, const CJumpItem &item, HWND hwnd )
520
523
{
521
524
Assert (GetWinVersion ()>=WIN_VER_WIN7);
522
- if (!item.pItem ) return false ;
525
+ if (!item.pItem )
526
+ return false ;
527
+
523
528
if (item.type ==CJumpItem::TYPE_ITEM)
524
529
{
525
- /* CString appid;
526
- {
527
- CItemManager::RWLock lock(&g_ItemManager,false,CItemManager::RWLOCK_ITEMS);
528
- appid=pAppInfo->GetAppid();
529
- }
530
- LOG_MENU(LOG_OPEN,L"Execute Item: name=%s, appid=%s",item.name,appid);*/
531
530
CComQIPtr<IShellItem> pItem (item.pItem );
532
531
if (!pItem)
533
532
return false ;
534
- /* CComString pName;
535
- if (FAILED(pItem->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING,&pName)))
536
- return false;
537
- wchar_t ext[_MAX_EXT];
538
- Strcpy(ext,_countof(ext),PathFindExtension(pName));
539
533
540
- // find the correct association handler by appid and invoke it on the item
541
- CComPtr<IEnumAssocHandlers> pEnumHandlers;
542
- if (ext[0] && SUCCEEDED(SHAssocEnumHandlers(ext,ASSOC_FILTER_RECOMMENDED,&pEnumHandlers)))
543
- {
544
- CComPtr<IAssocHandler> pHandler;
545
- ULONG count;
546
- while (SUCCEEDED(pEnumHandlers->Next(1,&pHandler,&count)) && count==1)
547
- {
548
- CComQIPtr<IObjectWithAppUserModelID> pObject=pHandler;
549
- if (pObject)
550
- {
551
- CComString pID;
552
- if (SUCCEEDED(pObject->GetAppID(&pID)))
553
- {
554
- // found explicit appid
555
- if (_wcsicmp(appid,pID)==0)
556
- {
557
- LOG_MENU(LOG_OPEN,L"Found handler appid");
558
- CComPtr<IDataObject> pDataObject;
559
- if (SUCCEEDED(pItem->BindToHandler(NULL,BHID_DataObject,IID_IDataObject,(void**)&pDataObject)) && SUCCEEDED(pHandler->Invoke(pDataObject)))
560
- return true;
561
- break;
562
- }
563
- }
564
- }
565
- pHandler=NULL;
566
- }
567
- pEnumHandlers=NULL;
568
-
569
- // find the correct association handler by exe name and invoke it on the item
570
- wchar_t targetPath[_MAX_PATH];
571
- targetPath[0]=0;
572
- {
573
- CComPtr<IShellItem> pItem;
574
- SHCreateItemFromIDList(pAppInfo->GetPidl(),IID_IShellItem,(void**)&pItem);
575
- CComPtr<IShellLink> pLink;
576
- if (pItem)
577
- pItem->BindToHandler(NULL,BHID_SFUIObject,IID_IShellLink,(void**)&pLink);
578
- CAbsolutePidl target;
579
- if (pLink && SUCCEEDED(pLink->Resolve(NULL,SLR_INVOKE_MSI|SLR_NO_UI|SLR_NOUPDATE)) && SUCCEEDED(pLink->GetIDList(&target)))
580
- {
581
- if (FAILED(SHGetPathFromIDList(target,targetPath)))
582
- targetPath[0]=0;
583
- }
584
- }
585
- if (targetPath[0] && SUCCEEDED(SHAssocEnumHandlers(ext,ASSOC_FILTER_RECOMMENDED,&pEnumHandlers)))
586
- {
587
- while (SUCCEEDED(pEnumHandlers->Next(1,&pHandler,&count)) && count==1)
588
- {
589
- CComString pExe;
590
- if (SUCCEEDED(pHandler->GetName(&pExe)))
591
- {
592
- if (_wcsicmp(targetPath,pExe)==0)
593
- {
594
- LOG_MENU(LOG_OPEN,L"Found handler appexe %s",targetPath);
595
- CComPtr<IDataObject> pDataObject;
596
- if (SUCCEEDED(pItem->BindToHandler(NULL,BHID_DataObject,IID_IDataObject,(void**)&pDataObject)) && SUCCEEDED(pHandler->Invoke(pDataObject)))
597
- return true;
598
- break;
599
- }
600
- }
601
- pHandler=NULL;
602
- }
603
- }
604
- }
605
- */
606
- // couldn't find a handler, execute the old way
607
534
SHELLEXECUTEINFO execute={sizeof (execute),SEE_MASK_IDLIST|SEE_MASK_FLAG_LOG_USAGE};
608
535
execute.nShow =SW_SHOWNORMAL;
609
536
CAbsolutePidl pidl;
@@ -617,9 +544,50 @@ bool ExecuteJumpItem( const CItemManager::ItemInfo *pAppInfo, const CJumpItem &i
617
544
618
545
if (item.type ==CJumpItem::TYPE_LINK)
619
546
{
620
- // invoke the link through its context menu
547
+ // Name: System.AppUserModel.HostEnvironment -- PKEY_AppUserModel_HostEnvironment
548
+ // Type: UInt32 -- VT_UI4
549
+ // FormatID: {9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, 14
550
+ static const PROPERTYKEY PKEY_AppUserModel_HostEnvironment = { {0x9F4C2855 , 0x9F79 , 0x4B39 , {0xA8 , 0xD0 , 0xE1 , 0xD4 , 0x2D , 0xE1 , 0xD5 , 0xF3 }}, 14 };
551
+
552
+ // Name: System.AppUserModel.ActivationContext -- PKEY_AppUserModel_ActivationContext
553
+ // Type: String -- VT_LPWSTR
554
+ // FormatID: {9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, 20
555
+ static const PROPERTYKEY PKEY_AppUserModel_ActivationContext = { {0x9F4C2855 , 0x9F79 , 0x4B39 , {0xA8 , 0xD0 , 0xE1 , 0xD4 , 0x2D , 0xE1 , 0xD5 , 0xF3 }}, 20 };
556
+
621
557
CComQIPtr<IContextMenu> pMenu (item.pItem );
622
- if (!pMenu) return false ;
558
+ CStringA params;
559
+
560
+ CComQIPtr<IShellLink> pLink (item.pItem );
561
+ if (pLink)
562
+ {
563
+ CComQIPtr<IPropertyStore> store (pLink);
564
+ if (store)
565
+ {
566
+ auto appId = GetPropertyStoreString (store, PKEY_AppUserModel_ID);
567
+ if (!appId.IsEmpty ())
568
+ {
569
+ CComPtr<IShellItem2> target;
570
+ if (SUCCEEDED (SHCreateItemInKnownFolder (FOLDERID_AppsFolder, 0 , appId, IID_PPV_ARGS (&target))))
571
+ {
572
+ ULONG modern = 0 ;
573
+ if (SUCCEEDED (target->GetUInt32 (PKEY_AppUserModel_HostEnvironment, &modern)) && modern)
574
+ {
575
+ CComQIPtr<IContextMenu> targetMenu;
576
+ if (SUCCEEDED (target->BindToHandler (nullptr , BHID_SFUIObject, IID_PPV_ARGS (&targetMenu))))
577
+ {
578
+ pMenu = targetMenu;
579
+ params = CT2CA (GetPropertyStoreString (store, PKEY_AppUserModel_ActivationContext));
580
+ }
581
+ }
582
+ }
583
+ }
584
+ }
585
+ }
586
+
587
+ // invoke the link through its context menu
588
+ if (!pMenu)
589
+ return false ;
590
+
623
591
HRESULT hr;
624
592
HMENU menu=CreatePopupMenu ();
625
593
hr=pMenu->QueryContextMenu (menu,0 ,1 ,1000 ,CMF_DEFAULTONLY);
@@ -633,6 +601,8 @@ bool ExecuteJumpItem( const CItemManager::ItemInfo *pAppInfo, const CJumpItem &i
633
601
{
634
602
CMINVOKECOMMANDINFO command={sizeof (command),CMIC_MASK_FLAG_LOG_USAGE};
635
603
command.lpVerb =MAKEINTRESOURCEA (id-1 );
604
+ if (!params.IsEmpty ())
605
+ command.lpParameters = params;
636
606
wchar_t path[_MAX_PATH];
637
607
GetModuleFileName (NULL ,path,_countof (path));
638
608
if (_wcsicmp (PathFindFileName (path),L" explorer.exe" )==0 )
0 commit comments