gpt4 book ai didi

c# - 从 wix 安装程序安装和注册 shell 扩展上下文菜单

转载 作者:行者123 更新时间:2023-11-30 14:08:40 25 4
gpt4 key购买 nike

我创建了 sharp shell 扩展,用于使用 .Net 自定义窗口的右键单击菜单上下文。该项目的结果是一个 .dll。我尝试使用服务器管理器工具安装和注册它,它与 sharp shell 工具一起存在并且它成功运行。现在我需要从我的 wix 项目安装和注册这个 shell 扩展,因为我需要用户安装我的应用程序并在安装后获得自定义窗口的右键单击上下文菜单。

我需要详细的步骤,因为我是 Wix 安装程序的新手。

最佳答案

以下是如何从 Wix 注册您的扩展程序:

首先您需要定义(在产品范围内)自定义操作以注册/注销您的扩展:

<Product>
<!-- ... -->
<CustomAction Id="InstallShell" FileKey="srm.exe" ExeCommand='install "[INSTALLFOLDER]\MyExtension.dll" -codebase' Execute="deferred" Return="check" Impersonate="no" />
<CustomAction Id="UninstallShell" FileKey="srm.exe" ExeCommand='uninstall "[INSTALLFOLDER]\MyExtension.dll"' Execute="deferred" Return="check" Impersonate="no" />
</Product>

然后您需要自定义安装执行顺序以启动这些自定义操作:

<Product>
<!-- ... -->
<InstallExecuteSequence>
<Custom Action="InstallShell" After="InstallFiles">NOT Installed</Custom>
<Custom Action="UninstallShell" Before="RemoveFiles">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
</InstallExecuteSequence>
</Product>

"MyExtension.dll"是您的 wix 项目中扩展 dll 资源的 ID:

<Component Guid="*">
<File Id="MyExtension.dll" KeyPath="yes" Source="bin\$(var.Configuration)\MyExtension.dll" />
</Component>

srm.exe 也一样:

<Component Guid="*">
<File Id="srm.exe" Source="packages\SharpShellTools.2.2.0.0\lib\srm.exe" KeyPath="yes" />
</Component>

您需要检索与您使用的 Sharpshell 版本关联的 srm.exe(我建议您使用 nuget 包)。您可以在此处找到相关信息: http://www.codeproject.com/Articles/653780/NET-Shell-Extensions-Deploying-SharpShell-Servers

希望对你有帮助;)

关于c# - 从 wix 安装程序安装和注册 shell 扩展上下文菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34199756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com