您可以使用Interope,在您的项目中引入"Windows Script Host Object Model" COM library。然后运行下面的代码:using System;
using System.Runtime.InteropServices;
using IWshRuntimeLibrary;namespace CreateShortcutCOM {
/// <summary>
/// This class creates a shortcut with COM interoperability
/// </summary>
class ShortcutDemo {
[STAThread]
static void Main(string[] args) {
// Get the app path and filename
string app = Environment.CurrentDirectory + @"\CreateShortcutCOM.exe"; try {
// Create a Windows Script Host Shell class
IWshShell_Class shell = new IWshShell_ClassClass();
// Define the shortcut file
IWshShortcut_Class shortcut = shell.CreateShortcut(app + ".lnk") as IWshShortcut_Class;
// Set all its properties
shortcut.Description = "Smart sample of creating shell shortcut";
shortcut.TargetPath = app;
shortcut.IconLocation = app + ",0";
// Save it
shortcut.Save();
}
catch(COMException ex) {
Console.WriteLine(ex.Message);
}
}
}
}
using System.Runtime.InteropServices;
using IWshRuntimeLibrary;namespace CreateShortcutCOM {
/// <summary>
/// This class creates a shortcut with COM interoperability
/// </summary>
class ShortcutDemo {
[STAThread]
static void Main(string[] args) {
// Get the app path and filename
string app = Environment.CurrentDirectory + @"\CreateShortcutCOM.exe"; try {
// Create a Windows Script Host Shell class
IWshShell_Class shell = new IWshShell_ClassClass();
// Define the shortcut file
IWshShortcut_Class shortcut = shell.CreateShortcut(app + ".lnk") as IWshShortcut_Class;
// Set all its properties
shortcut.Description = "Smart sample of creating shell shortcut";
shortcut.TargetPath = app;
shortcut.IconLocation = app + ",0";
// Save it
shortcut.Save();
}
catch(COMException ex) {
Console.WriteLine(ex.Message);
}
}
}
}
[InternetShortcut]
URL=http://www.webdiyer.com
modified=228928983然后保存为link.url,文件名随便起,但后缀必须是url,然后把它保存到桌面文件夹中即可,我的AspNetPager安装程序就是这么做的。--------------------------------
AspNetPager 免费分页控件4.2版发布,同时发布最新源代码,欢迎下载:http://www.webdiyer.com
URL=http://www.webdiyer.com
一般的,只能在客户端浏览器的收藏夹里添加链接、或者是将浏览器首页设置为你的网址,但都要客户点击确认才行。如果能随便在客户系统的任意地方添加文件,岂不都乱套啦?万一给你安装一个木马、超级冲击波,怎么办?