如果您的站点设置了favicon.ico,那么正常情况下该站点创建出来的快捷链接图标将是favicon.ico,
如图:
using System.Runtime.InteropServices;
using IWshRuntimeLibrary;
// 添加引用:COM下Windows Script Host Object Model
public bool Createlnk()
{
string app = "http://hi.baidu.com/cqjfb";
string location1 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites) + "\\邪恶的小嘴的空间.url";
string location2 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory) + "\\邪恶的小嘴的空间.url";
string location3 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Programs) + "\\邪恶的小嘴的空间.url";
try
{
// Create a Windows Script Host Shell class
IWshShell_Class shell = new IWshShell_ClassClass();
// Define the shortcut file
IWshURLShortcut shortcut = shell.CreateShortcut(location1) as IWshURLShortcut;
shortcut.TargetPath = app;
// Save it
shortcut.Save();
shortcut = shell.CreateShortcut(location2) as IWshURLShortcut;
shortcut.TargetPath = app;
// Save it
shortcut.Save();
shortcut = shell.CreateShortcut(location3) as IWshURLShortcut;
shortcut.TargetPath = app;
// Save it
shortcut.Save();
return true;
}
catch (COMException ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
如果要自定义快捷链接的图标,请使用
http://hi.baidu.com/cqjfb/blog/item/6a009653672683828e543066.html
中的方式创建快捷链接,可以实现自定义图标。: