您的位置:首页 > 编程语言 > C#

C#创建快捷方式

2007-11-29 09:23 302 查看
先添加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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: