當前位置:編程學習大全網 - 網站源碼 - c#如何獲取快捷方式的目標路徑,望知道的人給個提示,最好有源碼

c#如何獲取快捷方式的目標路徑,望知道的人給個提示,最好有源碼

引用COM組件Windows Script Host Object Model;

//設置壹個快捷方式

IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShellClass();

IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut("c:\\a.lnk");

shortcut.TargetPath = "notepad.exe";

shortcut.Arguments = "c:\\a.txt";

shortcut.Description = "My Shortcut";

shortcut.Hotkey = "CTRL+SHIFT+N";

shortcut.IconLocation = "notepad.exe, 0";

shortcut.Save();

//得到快捷方式屬性

shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut("c:\\x.lnk");

MessageBox.Show(ws.Description); //如果是取目標路徑的話,這個Description可能應該是TargetPath

  • 上一篇:好看的電影,誰有?壹個10分!!!都來看看!!!
  • 下一篇:centos幹什麽用的
  • copyright 2024編程學習大全網