实现下载到桌面快捷方式程序代码
代码如下 |
复制代码 |
<%
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.hzhuti.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保存快捷方式,下载到桌面的代码
代码如下 |
复制代码 |
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来实现,方法跟上面差不多的,只是代码不同
先创建一个文本,把以下代码复制进去,
代码如下 |
复制代码 |
<?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,需下载库
代码如下 |
复制代码 |
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++;
}
}
|
补充:Jsp教程,Java基础