【发布时间】:2018-01-19 20:13:59
【问题描述】:
我们在 Windows 的开始菜单中创建一个快捷方式,并为该快捷方式应用目标文件的图标。目标文件是Help & Manual 的帮助文件(后缀为.chm)。我们尝试了以下代码:
var lPath = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\ProductName\Help.lnk";
var lTargetPath = @"C:\Program Files\ManufacturerName\ProductName\Help.chm";
WshShell lWshShell = new WshShell();
IWshShortcut lShortcut = (IWshShortcut)lWshShell.CreateShortcut(lPath);
lShortcut.WorkingDirectory = lPath;
lShortcut.TargetPath = lTargetPath;
lShortcut.IconLocation = lTargetPath; // <-- I want to apply the same icon as the target file here.
目标 .chm 文件具有以下图标:
当我们执行这段代码时,开始菜单中的快捷方式如下所示:
如何自动应用目标文件的图标?
注意:当我通过 WIX 使用相同的路径创建快捷方式时,图标将应用于快捷方式。
【问题讨论】:
-
.chm文件不包含图标资源。 -
@SamAxe:当我通过 WIX 创建快捷方式时,使用相同的路径,然后图标将应用于快捷方式。