C# 创建一个文件夹快捷方式

来源:互联网 发布:数据库varchar长度 编辑:程序博客网 时间:2024/05/02 16:08
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
//通过该对象的 CreateShortcut 方法来创建 IWshShortcut 接口的实例对象
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(‘快捷方式名称’);//*.lnk,可以写写全路径名称,这样就不用设置WorkingDirectory 属性
shortcut.TargetPath = linkPath;//快捷方式指向路径
shortcut.WorkingDirectory = ‘快捷方式存放目录’;//就是将这个快捷方式放在哪个目录下,如果在CreateShortcut的时候用的全路径,这个步骤可以省略
shortcut.WindowStyle = 1;(透过快捷键打开文件夹的时候1.Normal window普通窗口,3.Maximized最大化窗口,7.Minimized最小化)
shortcut.Description = ‘快捷方式描述信息’;
shortcut.IconLocation = “自定义图标”
shortcut.Hotkey = "快捷键“;//hotkey如shift + A
 shortcut.Save();//保存
0 0
原创粉丝点击