問題:我需要創建快捷方式的目錄與在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();
你描述聽起來很OK,你可以張貼實際的代碼? –
@JonathanPotter完成 – PiotrK