给项目安装程序添加快捷方式
//添加以下引用COM 下 Windows Script Host Object Model然后
//using SystemRuntimeInteropServices;
//using IWshRuntimeLibrary;
private void AddShortcut()
{
string[] vPath = thistargetdirSplit(\)
string url = // + thisiis + / + vPath[vPathLength ];
try
{
string mysite = url;
//创建收藏夹快捷方式
string fav = SystemEnvironmentGetFolderPath(SystemEnvironmentSpecialFolderFavorites) + \MX系统url;
IWshShell_Class wshShell = new IWshShell_ClassClass()//创建 Windows Script Host Shell 类
IWshURLShortcut favShortcut = wshShellCreateShortcut(fav) as IWshURLShortcut;//定义快捷方式文件
favShortcutTargetPath = mysite;
favShortcutSave()//保存快捷方式
//创建桌面快捷方式
string desktop = SystemEnvironmentGetFolderPath(SystemEnvironmentSpecialFolderDesktop) + \MX系统url;
IWshURLShortcut desktopShortcut = wshShellCreateShortcut(desktop) as IWshURLShortcut;
desktopShortcutTargetPath = mysite;
desktopShortcutSave()//保存快捷方式
}
catch (Exception exc)
{
throw new Exception(创建快捷方式错误! + excMessage)
}
}