教程集 www.jiaochengji.com
教程集 >  脚本编程  >  java  >  正文 实现下载到桌面快捷方式程序代码

实现下载到桌面快捷方式程序代码

发布时间:2017-12-02   编辑:jiaochengji.com
教程集为您提供实现下载到桌面快捷方式程序代码等资源,欢迎您收藏本站,我们将为您提供最新的实现下载到桌面快捷方式程序代码资源
下面我们总结了两个利用php和asp实现把网站在用户桌面创建一个快捷方式的代码,有需要学习的朋友可参考一下。
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy2564')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy2564>

<%
id=request("id")
liehuo_net_url=request("liehuo_net_url")
If liehuo_net_url="" Then liehuo_net_url="挖坑部落"
Shortcut = "[InternetShortcut] " & vbCrLf
Shortcut = Shortcut & "URL=http://www.jiaochengji.com/" & vbCrLf
Shortcut = Shortcut & "IDList=" & vbCrLf
Shortcut = Shortcut & "IconFile=http://www.diaoxiong45.com/favicon.ico" & vbCrLf
Shortcut = Shortcut & "IconIndex=1" & vbCrLf
Shortcut = Shortcut & "[{000214A0-0000-0000-C000-000000000046}] " & vbCrLf
Shortcut = Shortcut & "Prop3=19,2 " & vbCrLf
Shortcut = Shortcut & " " & vbCrLf
Response.AddHeader "Content-Disposition", "attachment;filename="&liehuo_net_url&".url;"
Response.ContentType = "application/octet-stream"
Response.Write Shortcut
%>

asp.net

实现网页URL保存快捷方式,下载到桌面的代码

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy9535')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy9535>

string websitename, string url

HttpContext.Current.Response.ContentType = "APPLICATION/OCTET-STREAM";
            HttpContext.Current.Response.HeaderEncoding = System.Text.Encoding.UTF8;
            var name = HttpContext.Current.Request.Browser.Browser.ToLower().IndexOf("firefox") >= 0 ? HttpUtility.HtmlEncode(websitename) : HttpUtility.UrlEncode(websitename);
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" name);
            HttpContext.Current.Response.Write("[InternetShortcut]n");
            HttpContext.Current.Response.Write("URL=" url "n");
            HttpContext.Current.Response.Write("IDList=n");
            HttpContext.Current.Response.Write("IconFile=/images/favicon.icon");
            HttpContext.Current.Response.Write("IconIndex=1n");
            HttpContext.Current.Response.Write("[{000214A0-0000-0000-C000-000000000046}]n");
            HttpContext.Current.Response.Write("Prop3=19,2n");
            HttpContext.Current.Response.Write("[DEFAULT]n");
            HttpContext.Current.Response.Write("BASEURL=" url);
            HttpContext.Current.Response.End();


php

用PHP来实现,方法跟上面差不多的,只是代码不同
先创建一个文本,把以下代码复制进去,

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy9614')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy9614><?php
$Shortcut = "[InternetShortcut]
URL=http://www.diaoxiong45.com/
IDList=
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
";
Header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=挖坑部落.url;");
echo $Shortcut;
?>

JShortcut,需下载库

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy1017')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy1017>

http://alumnus.caltech.edu/~jimmc/jshortcut/

package com.test;
import net.jimmc.jshortcut.JShellLink;

public class TestS {
 public static void main(String[] args) {
  String jarFileName = "D:\mhtest";
  // create lnk file
  JShellLink link = new JShellLink();
  link.setFolder("C:\");
  link.setName("mhtest");
  link.setPath(jarFileName);
  link.save();


  // get the real file the lnk file link to.
  JShellLink link2 = new JShellLink("C:\", "mhtest");
  link2.load();
  String sPath = link2.getPath();
  System.out.print(sPath);
  int i = 0;
  i ;
 }
}

您可能感兴趣的文章:
Win8.1怎么把IE浏览器添加到桌面快捷方式
PHP创建桌面快捷方式实现代码
百度浏览器升级以后桌面快捷方式不能用了解决办法
php或asp创建网页桌面快捷方式
电脑显示桌面快捷方式不小心删除怎么办
Win10系统创建EDGE浏览器桌面快捷图标教程
ASP.NET控件利用Control.ContextMenu加入快捷菜单
添加网页桌面快捷方式的代码(js、asp、c#)
PhpStorm中返回上次编辑位置的快捷键使用方法
Windows 7系统桌面没有IE浏览器图标解决技巧

[关闭]
~ ~