【转】在C#2005中创建快捷方式
2008-05-26 23:46
232 查看
转自: http://www.cnblogs.com/cfanwolf/
1using System;
2using System.Collections.Generic;
3using System.Text;
4using IWshRuntimeLibrary;
5//在引用里面添加“Windows Script Host Object Model”
6namespace Shortcuts
7
上面的代码就是在C#中创建快捷方式的核心部分。其中这个类需要在引用中添加“Windows Script Host Object Model”并且USING IWshRuntimeLibrary
下面是一个在VS.NET2005中制作的WINFORM程序。这个程序将演示如何在桌面上创建自己的快捷方式。
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8
9namespace 创建快捷方式
10{
11 public partial class Form1 : Form
12 {
13 public Form1()
14 {
15 InitializeComponent();
16 }
17
18 private void button1_Click(object sender, EventArgs e)
19 {
20 Shortcuts.Lnk CreateLnk = new Shortcuts.Lnk();
21 CreateLnk.CreateShortcutLnk(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
22 Application.ExecutablePath, "我的应用程序", "我的应用程序", Application.ExecutablePath);
23 MessageBox.Show("成功创建快捷方式");
24 }
25 }
26}
1using System;
2using System.Collections.Generic;
3using System.Text;
4using IWshRuntimeLibrary;
5//在引用里面添加“Windows Script Host Object Model”
6namespace Shortcuts
7
上面的代码就是在C#中创建快捷方式的核心部分。其中这个类需要在引用中添加“Windows Script Host Object Model”并且USING IWshRuntimeLibrary
下面是一个在VS.NET2005中制作的WINFORM程序。这个程序将演示如何在桌面上创建自己的快捷方式。
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8
9namespace 创建快捷方式
10{
11 public partial class Form1 : Form
12 {
13 public Form1()
14 {
15 InitializeComponent();
16 }
17
18 private void button1_Click(object sender, EventArgs e)
19 {
20 Shortcuts.Lnk CreateLnk = new Shortcuts.Lnk();
21 CreateLnk.CreateShortcutLnk(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
22 Application.ExecutablePath, "我的应用程序", "我的应用程序", Application.ExecutablePath);
23 MessageBox.Show("成功创建快捷方式");
24 }
25 }
26}
相关文章推荐
- 在C#2005中创建快捷方式
- [懵懂边缘] 用Visual C# 2005创建快捷方式
- C#创建快捷方式
- C#创建快捷方式
- C#创建快捷方式
- [No000074]C#创建桌面快捷方式
- c#创建快捷方式
- C#实现创建桌面快捷方式与添加网页到收藏夹的示例
- 用Visual C# 2005创建快捷方式
- c# 纯代码方式创建快捷方式
- C# 创建快捷方式
- 【转及整理】C#管理快捷方式文件创建
- VS2008 c# 创建快捷方式 卸载程序
- 用Visual C# 2005创建快捷方式
- C# 创建快捷方式,如建立桌面和程序夹的快捷方式链接,并且上ALL USERS级别
- C#入门学习-----菜单应用(添加剂快捷方式、设置菜单项是否可用、修改菜单字体、创建级联菜单、级联菜单的动态合并)
- 如何使用C#代码创建快捷方式文件详解
- 使用C#创建快捷方式
- c#通过纯代码创建桌面快捷方式、创建程序菜单项、将网页添加到收藏夹
- 在C#中快速创建快捷方式到指定位置