C#创建桌面快捷方式
2015-10-27 19:10
471 查看
1、添加引用Windows Script Host Object Model,并引用命名空间using IWshRuntimeLibrary;
2、代码
3、结果及属性查看
2、代码
using System; using IWshRuntimeLibrary; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void CreateShortCut() { string DesktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);//得到桌面文件夹 WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(DesktopPath + "\\我的快捷方式.lnk"); shortcut.TargetPath = @"D:\\kankan\\"; shortcut.Arguments = "";// 参数 shortcut.Description = "我用C#创建的快捷方式"; shortcut.WorkingDirectory = @"D:\\kankan";//程序所在文件夹,在快捷方式图标点击右键可以看到此属性 //shortcut.IconLocation = @"D:\software\cmpc\zy.exe,0";//图标 shortcut.Hotkey = "CTRL+SHIFT+Z";//热键 shortcut.WindowStyle = 1; shortcut.Save(); this.Close(); } private void button1_Click(object sender, EventArgs e) { CreateShortCut(); } } }
3、结果及属性查看
相关文章推荐
- C#操作ini文件
- C#操作系统计划任务
- C#操作windows服务,安装、卸载、停止、启动
- C# 6.0 (C# vNext) 的新功能:Expression Bodied Functions and Properties
- C# WPF DataGrid控件实现三级联动
- C#中TransactionScope的使用方法和原理
- 私人C#笔记
- C# 一步一步完成一个简单的计算器 第一步---搭建计算器界面
- 问题:C# TrimEnd 去掉最后的逗号;结果: C#中 TrimEnd()用法
- 堆排序(C#)
- 4000 堆排序(C#)
- C# 不复制到本地(软件当前目录)引用程序集;
- 利用C#Marshal类实现托管和非托管的相互转换
- C#中的一些技巧
- C# Process.Start()方法详解
- csharp: InvokeHelper
- C#中方法的参数的四种类型
- (原创)c#学习笔记06--函数06--委托
- C#日期格式转换大全
- c#基础3