0

问题:我需要在 C# 中使用自定义图标创建目录的快捷方式(没有.NET API)

到目前为止,我已经完成了:在我的 C# 代码中,我正在查询 IShellLink 对象(实际上是 IShellLinkA),通过 SetPath 将其目标路径设置为@"S:\my\myDirectory\"(我也尝试不使用最后一个斜杠),通过 SetIconLocation 将图标设置为,而@"S:\my\myDirectory\icon.ico, 0"不是调用Save(@"S:\foo.lnk", true);重要的是,这S:是一个具有写访问权限的网络驱动器

我在资源管理器下获得带有正确图标的快捷方式,但双击后我收到波兰语错误消息“Windows 正在搜索文件 myDirectory,如果您知道该位置使用浏览功能”。当我右键单击快捷方式并选择属性时,我得到"Target type: file". 当我在资源管理器下手动创建目录的快捷方式时,有"Target type: directory"

我肯定遗漏了一些明显的东西,但我花了过去 30 分钟在 Google 和 MSDN 上搜索“快捷方式/IShellLink 到目录”,但没有发现任何用处

编辑:根据要求发布来源:

我正在使用这个站点的 IShellLink 实现,我的代码非常简单:

ShellShortcut shortcut = new ShellShortcut(@"S:\foo.lnk");
shortcut.Description = "Sample item";
shortcut.IconPath = @"S:\my\myDirectory\icon.ico";
shortcut.IconIndex = Convert.ToInt32(0);
shortcut.Path = @"S:\my\myDirectory\";
shortcut.WorkingDirectory = @"S:\my\myDirectory\";
shortcut.Save();
4

1 回答 1

0

看来我需要新的眼睛:/路径名中很难看到拼写错误(l 而不是 i)...

于 2013-04-01T15:25:53.340 回答