创建IE快捷方式

类别:.NET开发 点击:0 评论:0 推荐:

/// ============?? SpecialFolder ============
///
/// ApplicationData? ??@"C:\Documents and Settings\whj\Application Data"
/// CommonApplicationData?@"C:\Documents and Settings\All Users\Application Data"
/// CommonProgramFiles??@"C:\Program Files\Common Files"
/// Cookies?????@"C:\Documents and Settings\whj\Cookies"
/// Desktop?????@"C:\Documents and Settings\whj\桌面"
/// DesktopDirectory??@"C:\Documents and Settings\whj\桌面"
/// Favorites????@"C:\Documents and Settings\whj\Favorites"
/// History?????@"C:\Documents and Settings\whj\Local Settings\History"
/// InternetCache???@"C:\Documents and Settings\whj\Local Settings\Temporary Internet Files"
/// LocalApplicationData?@"C:\Documents and Settings\whj\Local Settings\Application Data"
/// MyComputer
/// MyMusic
/// MyPictures????@"C:\Documents and Settings\whj\My Documents\My Pictures"
/// Personal????@"C:\Documents and Settings\whj\My Documents"
/// ProgramFiles???@"C:\Program Files"
/// Programs????@"C:\Documents and Settings\whj\「开始」菜单\程序"
/// Recent?????@"C:\Documents and Settings\whj\Recent"
/// SendTo?????@"C:\Documents and Settings\whj\SendTo"
/// StartMenu????@"C:\Documents and Settings\whj\「开始」菜单"
/// Startup?????@"C:\Documents and Settings\whj\「开始」菜单\程序\启动"
/// System?????@"C:\WINNT\system32"
/// Templates????@"C:\Documents and Settings\whj\Templates"

private void CreateShortcut(string Title , string URL)
{
?string strFavoriteFolder ;

?// “收藏夹”中 创建 IE 快捷方式
?strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
?CreateShortcutFile(Title,URL,strFavoriteFolder);

?// “ 桌面 ”中 创建 IE 快捷方式
?strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
?CreateShortcutFile(Title,URL,strFavoriteFolder);

?// “ 链接 ”中 创建 IE 快捷方式
?strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites)+"\\链接";
?CreateShortcutFile(Title,URL,strFavoriteFolder);

?//「开始」菜单中 创建 IE 快捷方式
?strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
?CreateShortcutFile(Title,URL,strFavoriteFolder);
?
}

private void CreateShortcutFile(string Title , string URL, string SpecialFolder)
{
?// Create shortcut file, based on Title
?System.IO.StreamWriter objWriter = System.IO.File.CreateText(SpecialFolder + "\\" + Title + ".url" );
?// Write URL to file
?objWriter.WriteLine("[InternetShortcut]");
?objWriter.WriteLine("URL=" + URL);
?// Close file
?objWriter.Close();
}

??private void button1_Click(object sender, System.EventArgs e)
??{
???CreateShortcut("TestIEShortCut","http://blog.csdn.net/LuckyJan/");
??}

本文地址:http://com.8s8s.com/it/it44336.htm