Home >Backend Development >PHP Tutorial >Multiple ways to create shortcuts to desktop from web pages_PHP tutorial

Multiple ways to create shortcuts to desktop from web pages_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-20 11:11:571852browse

We will see that many websites not only have a homepage set up, but also add a favorite to a desktop shortcut. Now I will introduce to you various methods of creating a shortcut to the desktop from a web page. Friends in need can refer to it.

The simplest js implementation method

The code is as follows Copy code
 代码如下 复制代码

<script> </script>

function toDesktop(sUrl,sName){ 

try 

var WshShell = new ActiveXObject("WScript.Shell"); 

var oUrlLink = WshShell.CreateShortcut(WshShell.SpecialFolders("Desktop") + "" + sName + ".url"); 

oUrlLink.TargetPath = sUrl; 

oUrlLink.Save(); 

catch(e) 

alert("请点击弹出对话框的:是 "); 

 

 

 

复制代码

$Shortcut = "[InternetShortcut] 

URL=http://www.bkjia.com 

IconFile=http://www.bkjia.com/favicon.ico 

IconIndex=0 

HotKey=1613 

IDList= 

[{000214A0-0000-0000-C000-000000000046}] 

Prop3=19,2"; 

header("Content-Type: application/octet-stream"); 

header("Content-Disposition: attachment; filename=蜕变无忧.url"); 

echo $Shortcut; 

?> 


发送到桌面 

{ var WshShell = new ActiveXObject("WScript.Shell"); var oUrlLink = WshShell.CreateShortcut(WshShell.SpecialFolders("Desktop") + "" + sName + ".url"); oUrlLink.TargetPath = sUrl; oUrlLink.Save(); } catch(e) { alert("Please click on the pop-up dialog box: Yes "); } } script> Inadequacy: If the browser has security settings, we The above method cannot be used. Friends who write PHP programs may also know a way, the code is as follows
The code is as follows Copy code
$Shortcut = "[InternetShortcut] URL=http://www.bkjia.com IconFile=http://www.bkjia.com/favicon.ico IconIndex=0 HotKey=1613 IDList= [{000214A0-0000-0000-C000-000000000046}] Prop3=19,2"; header ("Content-Type: application/octet-stream"); ​​header("Content-Disposition: attachment; filename= Transformation Wuyou.url"); echo $Shortcut; ?>
Send to desktop


asp.net程序员可能也知道如下代码

 

 代码如下
 代码如下 复制代码
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CreateShortcut : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
{
}
///
/// 创建快捷方式
///

/// 标题
/// URL地址
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);
}
///
/// 创建快捷方式
///

/// 标题
/// URL地址
/// 特殊文件夹
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 btnShortcut_Click(object sender, System.EventArgs e)
{
CreateShortcut("脚本之家", http://www.bkjia.com);
}
}
复制代码
using System;
using System.Data;
using System.Configuration; using System.Collections;

using System.Web;

using System.Web.Security; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class CreateShortcut : System.Web.UI.Page {   protected void Page_Load(object sender, EventArgs e) { } /// /// 创建快捷方式 ///
/// 标题 /// URL地址 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); } /// /// 创建快捷方式 /// /// 标题 /// URL地址 /// 特殊文件夹 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 btnShortcut_Click(object sender, System.EventArgs e) { CreateShortcut("脚本之家", http://www.bkjia.com); } } http://www.bkjia.com/PHPjc/444613.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444613.htmlTechArticle我们会看到很多的网站不但有设置首页,加入收藏同时还有一个加和到桌面快捷方式的功能,下面我来给大家介绍网页创建快捷方式到桌面...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn