有条件地安装 shell 扩展

Install shell extension conditionally

参考:将打包的桌面应用程序与文件资源管理器集成 https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/integrate-packaged-app-with-file-explorer

我现在知道如何在我的 win32 打包桌面应用程序的文件资源管理器中安装 shell 扩展自定义菜单项。但我想给用户一个选择,他是否真的想要 shell 扩展。有没有办法在 Appx 清单中做到这一点?

Microsoft 删除了自定义 MSIX 安装 GUI 的选项,这意味着您无法创建自定义选项,让用户选择是否需要 shell 扩展。

因此,据我所知,appxmanifest 架构不支持 shell 扩展的条件安装。

Microsoft 建议在您的应用程序中移动所有选项配置,包括 EULA 和许可证注册程序。因此,理论上您可以尝试从您的应用程序添加 shell 注册 - 我从未尝试过,但上面来自 Simon Mourier 的链接可能会有所帮助。

如果您实施 IExplorerCommandState interface which has the IExplorerCommandState::GetState method

,则可以解决该问题

Implement this interface when you need to determine the command state dynamically (for instance, based on an item's properties). This interface provides the same functionality as IExplorerCommand::GetState, without the overhead of that interface's additional methods. Implement IExplorerCommandState when you only need to compute the command state