我可以设置通过跳转列表启动的任意进程的 AppUserModelID 吗? [英] can I set the AppUserModelID of an arbitrary process launched through a jumplist?

查看:18
本文介绍了我可以设置通过跳转列表启动的任意进程的 AppUserModelID 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 C++ 编写的简单控制台应用程序,它充当通过它的跳转列表启动另一个应用程序的存根.目的是向不支持此功能的应用程序添加跳转列表功能.称之为 stub.exe.运行 stub.exe 时,它​​会使用以下步骤创建自定义跳转列表(取自 MS 示例):

I have a simple console application written in C++ that acts as a stub for launching another application through it's jumplist. Purpose is to add jumplist abilities to applications that do not support this. Call it stub.exe. When running stub.exe it creates a custom jumplist using these steps (taken right form the MS samples):

create an ICustomDestinationList
ICustomDestinationList::BeginList()
create an IObjectCollection
for_each item_to_add
  create an IShellLink, set its path/arguments/title/icon
  add IShellLink to the IObjectCollection
get the IObjectArray interface from the IObjectCollection
call ICustomDestinationList::AddUserTasks( IObjectArray interface )
ICustomDestinationList::CommitList()

将 stub.exe 固定到任务栏并右键单击它时,会出现 jumpilst,其中包含添加的所有 IShellLink.当点击一个项目时,它会启动相应的进程.

When pinning stub.exe to the taskbar and right-clicking it, the jumpilst appears and it contains all IShellLinks added. When clicking an item, it will launch the corresponding process.

现在我希望通过此跳转列表启动的进程将其窗口分组在 stub.exe 的任务栏图标下,而不是拥有自己的组.他们让这个工作的关键似乎是 AppUsermodelID.这是我到目前为止尝试过的:

Now I'd like a process launched through this jumplist have it's window(s) grouped under stub.exe's taskbar icon, instead of having it's own group. They key to get this working seems to be the AppUsermodelID. This is what I tried so far:

  • 仅用于测试,创建几个快捷方式并通过 IPropertyStore->SetValue( PKEY_AppUserModel_ID, "id" ) 设置 id.事实上,当启动这些快捷方式时,它们将全部归到同一个任务栏图标下.
  • 由于快捷方式可以满足我的要求,我尝试将快捷方式添加到 stub.exe 的跳转列表:无效.快捷方式甚至没有出现在跳转列表中(也许没有快捷方式的快捷方式?),但所有方法都返回 S_OK
  • 在添加到跳转列表的每个 IShellLink 上设置 PKEY_AppUserModel_ID:无效
  • 调用 ICustomDestinationList->SetAppID():无效
  • 尝试使用 SHAddToRecentDocs 而不是使用 SubTasks:没有效果.最近的文档列表不显示.但现在事情变得一团糟.在负责固定任务栏项目的快捷方式(%APPDATA%/Roaming/Microsoft/Internet Explorer/Quick Launch/User Pinned/TaskBar 中的那个)上设置 AppUserModelID 后,跳转列表发生了变化:它不显示任务"' 项目,但确实显示了最近"和我使用 SHAddToRecentDocs 添加的项目.现在,当单击它们时,我会看到一个对话框,其标题以 'd:\desktop' 开头,后跟中文字符.将鼠标悬停在跳转列表中的项目也会显示中文字符,而不是我设置的描述.

问题:

  1. 跳转列表中的汉字是怎么回事?
  2. 为什么在任务栏快捷方式上设置应用 ID 会在任务"和最近"部分之间切换,为什么它们不同时存在?
  3. 如果可能的话,有什么方法可以实现我真正想要的:自定义跳转列表,其中启动的项目将分组在任务栏图标下?(请注意,我计划启动的进程目前没有设置其应用程序 ID)

推荐答案

这里没有太多反应;]

与此同时,我设法自己解决了主要问题;这不是一个简单的解决方案,但它满足了要求:一个程序在后台运行并安装一个 CBT 钩子.每次应用程序创建一个窗口(HookProc 代码 = HCBT_CREATEWND)时,钩子都会根据包含路径和所需应用程序 ID 的映射检查应用程序的路径.如果找到匹配项,则设置 HWND 的应用程序 ID.由于这发生在窗口实际显示之前并与自定义任务列表结合在一起,因此从用户的角度来看,该应用程序的行为就像支持最近/固定文档列表的应用程序一样.

In the meantime I managed to solve the main problem myself; it's not quite a straightforward solution but it fullfills the requirements: a program runs in the backround and installs a CBT hook. Each time an application creates a window (HookProc code = HCBT_CREATEWND), the hook checks the application's path against a map containing paths and desired application ids. If a match is found, the application id of the HWND is set. Since this occurs before the window is actually shown and is combined with the custom task list, from a user's point of view the application behaves just like one that does support a recent/pinned document list.

这篇关于我可以设置通过跳转列表启动的任意进程的 AppUserModelID 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆