转自: 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{
8 public class Lnk
9 {
10 //"FolderPath"快捷方式存放的位置
11 //"PathLink"指向连接的文件
12 //"LnkName"快捷方式的文件
13 //"LnkNote"快捷方式的备注
14 //"IconLocationPath"指定快捷方式的图标
15 public void CreateShortcutLnk(string FolderPath, string PathLink, string LnkName, string LnkNote, string IconLocationPath)
16 {
17 try
18 {
19 WshShell shell = new WshShell();
20 IWshShortcut Shortcut = (IWshShortcut)shell.CreateShortcut(FolderPath + "\\" + LnkName + ".lnk");
21 Shortcut.TargetPath = PathLink;
22 Shortcut.WindowStyle = 1;
23 Shortcut.Description = LnkNote;
24 Shortcut.IconLocation = IconLocationPath;
25 Shortcut.Save();
26 }
27 catch
28 {
29 throw new Exception("出错了");
30 }
31 }
32 }
33}
34
下面是一个在VS.NET2005中制作的WINFORM程序。这个程序将演示如何在桌面上创建自己的快捷方式。

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26
