国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

網(wǎng)頁創(chuàng)建快捷方式到桌面多種方法

2024-05-04 21:48:33
字體:
供稿:網(wǎng)友

我們會看到很多的網(wǎng)站不但有設(shè)置首頁,加入收藏同時還有一個加到桌面快捷方式的功能,下面我來給大家介紹網(wǎng)頁創(chuàng)建快捷方式到桌面多種方法介紹,有需要的朋友可參考.

最簡單的js實現(xiàn)方法,代碼如下:

  1. <script language="JavaScript">  
  2.  
  3. function toDesktop(sUrl,sName){  
  4.  
  5. try  
  6.  
  7. {  
  8.  
  9. var WshShell = new ActiveXObject("WScript.Shell");  
  10.  
  11. var oUrlLink = WshShell.CreateShortcut(WshShell.SpecialFolders("Desktop") + "/" + sName + ".url");  
  12.  
  13. oUrlLink.TargetPath = sUrl;  
  14.  
  15. oUrlLink.Save();  
  16.  
  17. }  
  18.  
  19. catch(e)  
  20.  
  21. {  
  22.  
  23. alert("請點擊彈出對話框的:是 ");  
  24.  
  25. }  
  26.  
  27. }  
  28.  
  29. </script>  
  30.  
  31. <input name="btn" type="button" id="btn" value="把百度創(chuàng)建快捷方式到桌面" onClick="toDesktop('http://www.survivalescaperooms.com/','百度一下,你就知道!')">  
  32.  
  33. <input name="btn" type="button" id="btn" value="C盤" onClick="toDesktop('file://C:','C盤')">  

不足:這樣做如果瀏覽器做了安全設(shè)置我們是不能使用上面的方法的,寫php程序的朋友可能也知道一種辦法,代碼如下:

  1. <?php  
  2. $Shortcut = "[InternetShortcut]  
  3.  
  4. URL=http://www.survivalescaperooms.com  
  5.  
  6. IconFile=http://www.survivalescaperooms.com/favicon.ico  
  7.  
  8. IconIndex=0  
  9.  
  10. HotKey=1613  
  11.  
  12. IDList=  
  13.  
  14. [{000214A0-0000-0000-C000-000000000046}]  
  15.  
  16. Prop3=19,2";  
  17.  
  18. header("Content-Type: application/octet-stream");  
  19.  
  20. header("Content-Disposition: attachment; filename=蛻變無憂.url");  
  21.  
  22. echo $Shortcut;  
  23.  
  24. ?> 
  25. <a href="">發(fā)送到桌面</a>  

asp.net程序員可能也知道如下代碼:

  1. using System;  
  2. using System.Data;  
  3. using System.Configuration;  
  4. using System.Collections;  
  5. using System.Web;  
  6. using System.Web.Security;  
  7. using System.Web.UI;  
  8. using System.Web.UI.WebControls;  
  9. using System.Web.UI.WebControls.WebParts;  
  10. using System.Web.UI.HtmlControls;  
  11. public partial class CreateShortcut : System.Web.UI.Page  
  12. {  
  13.   protected void Page_Load(object sender, EventArgs e)  
  14. {  
  15. }  
  16. /// <summary>  
  17. /// 創(chuàng)建快捷方式  
  18. /// </summary>  
  19. /// <param name="Title">標(biāo)題</param>  
  20. /// <param name="URL">URL地址</param>  
  21. private void CreateShortcut(string Title, string URL)  
  22. {  
  23. string strFavoriteFolder;  
  24. // “收藏夾”中 創(chuàng)建 IE 快捷方式  
  25. strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites);  
  26. CreateShortcutFile(Title, URL, strFavoriteFolder);  
  27. // “ 桌面 ”中 創(chuàng)建 IE 快捷方式  
  28. strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);  
  29. CreateShortcutFile(Title, URL, strFavoriteFolder);  
  30. // “ 鏈接 ”中 創(chuàng)建 IE 快捷方式  
  31. strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites) + "/鏈接";  
  32. CreateShortcutFile(Title, URL, strFavoriteFolder);  
  33. //「開始」菜單中 創(chuàng)建 IE 快捷方式  
  34. strFavoriteFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);  
  35. CreateShortcutFile(Title, URL, strFavoriteFolder);  
  36. }  
  37. /// <summary>  
  38. /// 創(chuàng)建快捷方式  
  39. /// </summary>  
  40. /// <param name="Title">標(biāo)題</param>  
  41. /// <param name="URL">URL地址</param>  
  42. /// <param name="SpecialFolder">特殊文件夾</param>  
  43. private void CreateShortcutFile(string Title, string URL, string SpecialFolder)  
  44. {  
  45. // Create shortcut file, based on Title  
  46. System.IO.StreamWriter objWriter = System.IO.File.CreateText(SpecialFolder + "/" + Title + ".url");  
  47. // Write URL to file  
  48. objWriter.WriteLine("[InternetShortcut]");  
  49. objWriter.WriteLine("URL=" + URL);  
  50. // Close file  
  51. objWriter.Close();  
  52. }  
  53. private void btnShortcut_Click(object sender, System.EventArgs e)  
  54. {  
  55. CreateShortcut("php粉絲網(wǎng)", http://www.survivalescaperooms.com);  
  56. }  
  57. }

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 富源县| 天祝| 且末县| 游戏| 陈巴尔虎旗| 萍乡市| 房山区| 安国市| 金湖县| 桑日县| 滦南县| 南宁市| 民勤县| 奈曼旗| 正定县| 徐水县| 五指山市| 安仁县| 乐东| 砚山县| 永安市| 江安县| 遂宁市| 泗阳县| 重庆市| 周口市| 三江| 苍南县| 三门峡市| 浮山县| 土默特右旗| 泽普县| 青龙| 方山县| 山阳县| 汉沽区| 衡山县| 呼伦贝尔市| 彭州市| 平定县| 遂川县|