asp.net页面功能之【设为桌面图标】

第一步:创建一个空页面,如: SetDesktop.aspx【名字随便叫,不限定】

第二步:后台代码

 1 protected void Page_Load(object sender, EventArgs e)   
2 {
3 Response.Clear();
4 Response.ContentType = "APPLICATION/OCTET-STREAM";
5
6 //解决中文乱码
7 Response.Buffer = true;
8 Response.Charset = "gb2312";
9 Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
10 Response.AppendHeader("content-disposition", "attachment;filename=\"" + System.Web.HttpUtility.UrlEncode("百度", System.Text.Encoding.UTF8) + ".url\"");
11
12 Response.Write("[InternetShortcut] \r\n");
13 Response.Write("URL=http://www.baidu.com/ \r\n"); //链接
14 Response.Write("IDList= \r\n");
15 Response.Write("IconFile= \r\n"); //图标文件
16 Response.Write("IconIndex=1 \r\n");
17 Response.Write("[{000214A0-0000-0000-C000-000000000046}] \r\n");
18 Response.Write("Prop3=19,2 \r\n");
19 Response.End();
20 }


或:

   

 1  protected void SetShortCut()
2 {
3 Response.ClearContent();
4
5 if (HttpContext.Current.Request.Browser.Browser != "IE")
6 {
7 HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=\"谷歌.url\"");
8 }
9 else
10 {
11 string sitename = HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes("谷歌.url"));
12 Response.AddHeader("content-disposition", "attachment; filename=" + sitename);
13 }
14 Response.ContentType = "APPLICATION/OCTET-STREAM";
15
16 Response.Write("[InternetShortcut]\r\n");
17 Response.Write("URL=http://www.google.com\r\n");
18 Response.Write("IDList=\r\n");
19 Response.Write("[{000214A0-0000-0000-C000-000000000046}]\r\n");
20 Response.Write(" Prop3=19,2\r\n");
21 Response.End();
22
23 }


 

第三步:调用<a href="SetDesktop.aspx">设为桌面图标</a>

转载于:https://www.cnblogs.com/zhangtao1212/archive/2012/03/27/2420018.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值