安装和注册 shell 扩展上下文菜单 来自 wix 安装程序

Installing and registering shell extension Context menu From wix installer

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

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

以下是从 Wix 注册扩展程序的方法:

首先,您需要(在产品范围内)为 register/unregister 您的扩展程序定义自定义操作:

<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

希望对您有所帮助 ;)