C#创建快捷方式

来源:互联网 发布:windows下多线程编程 编辑:程序博客网 时间:2024/04/30 00:18

先添加IWshRuntimeLibrary引用

// Create a new instance of WshShellClass
   WshShellClass WshShell = new WshShellClass();

   // Create the shortcut
   IWshRuntimeLibrary.IWshShortcut MyShortcut;

   // Choose the path for the shortcut
   MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(@"C:/MyShortcut.lnk");

   // Where the shortcut should point to
   MyShortcut.TargetPath = Application.ExecutablePath;

   // Description for the shortcut
   MyShortcut.Description = "Launch My Application";

   // Location for the shortcut's icon
   MyShortcut.IconLocation = Application.StartupPath + @"/App.ico";

   // Create the shortcut at the given path
   MyShortcut.Save(); 

示例源码下载 http://download.csdn.net/source/297466

原创粉丝点击