C#怎么创建快捷方式?
C#怎么创建快捷方式到桌面来启动可执行程序?高手给个例子!
2011-04-12 17:58
程序代码:using System;
using System.Collections.Generic;
using System.Collections;
using using System.Reflection;
using IWshRuntimeLibrary;
namespace Test
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
public static void Main()
{
//创建快捷方式
//建立对象
WshShell shell = new WshShell();
//生成快捷方式文件,指定路径及文件名
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) +"\\" + "sunlunjun.lnk");
//快捷方式指向的目标
shortcut.TargetPath = (System.Environment.CurrentDirectory, "myService.exe");
//起始目录
shortcut.WorkingDirectory = System.Environment.CurrentDirectory;
//窗口类型
shortcut.WindowStyle = 1;
//描述
shortcut.Description = "my Application";
//图标
shortcut.IconLocation = System.Environment.SystemDirectory + "\\" + "shell32.dll, 165";
//保存,注意一定要保存,否则无效
shortcut.Save();
}
}
}
1、快捷方式包含如下数据:
2011-04-13 06:34