2013-03-31 158 views
-1

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

到目前为止,我已经做了:在我的C#代码我查询IShellLink对象(实际上是IShellLinkA),通过SetPath将其目标路径设置为@"S:\my\myDirectory\"(我也尝试过没有最后一个斜杠),通过SetIconLocation将该图标设置为@"S:\my\myDirectory\icon.ico, 0",比调用Save(@"S:\foo.lnk", true);如果这很重要,则S:是一个带写访问

我得到下探险适当的图标快捷方式,但双击后,我得到了波兰的错误消息“Windows搜索文件myDirect ory,如果你知道位置使用浏览功能“。当我用鼠标右键单击该快捷方式,选择属性,我得到"Target type: file"。当我手动创建快捷方式的目录下的探险家,有"Target type: directory"

我肯定失去了一些东西很明显,但我已经花了最后30分钟搜索谷歌和MSDN的“快捷方式/对的IShellLink目录”,并没有发现任何使用

编辑:发布来源,要求:

我使用实施的IShellLink从this网站,我的代码很简单:

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(); 
+1

你描述听起来很OK,你可以张贴实际的代码? –

+0

@JonathanPotter完成 – PiotrK

回答

0

它似乎我需要新的眼睛:/有一个很难看到错字(L,而不是我)的路径名称...