【转载】C#.Net 创建网页快捷方式
using System.Runtime.InteropServices;
using IWshRuntimeLibrary; // 添加引用:COM下Windows Script Host Object Model public bool Createlnk()
{
string app = "http://www.cnblogs.com/iack";
string location1 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites) + "\\iack在cnblogs.url";
string location2 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory) + "\\iack在cnblogs.url";
string location3 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Programs) + "\\iack在cnblogs.url"; try
{
// Create a Windows Script Host Shell class
IWshShell_Class shell = new IWshShell_ClassClass();
// Define the shortcut file
IWshURLShortcut shortcut = shell.CreateShortcut(location1) as IWshURLShortcut;
shortcut.TargetPath = app;
// Save it
shortcut.Save(); shortcut = shell.CreateShortcut(location2) as IWshURLShortcut;
shortcut.TargetPath = app;
// Save it
shortcut.Save(); shortcut = shell.CreateShortcut(location3) as IWshURLShortcut;
shortcut.TargetPath = app;
// Save it
shortcut.Save(); return true;
} catch (COMException ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
如果要自定义快捷链接的图标,请使用
using System.Runtime.InteropServices;
using IWshRuntimeLibrary; // 添加引用:COM下Windows Script Host Object Model public bool Createlnk()
{
string app = "c:\windows\system32\calc.exe";
string lnklocation = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory) + "\\计算器.lnk";
try
{
// Create a Windows Script Host Shell class
IWshShell_Class shell = new IWshShell_ClassClass();
// Define the shortcut file
IWshShortcut_Class shortcut = shell.CreateShortcut(lnklocation) as IWshShortcut_Class;
shortcut.TargetPath = app;
shortcut.Description = lnkDesc;
shortcut.IconLocation = app + ",0"; shortcut.Save();
return true;
}
catch (COMException ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
可以实现自定义图标。:
【转载】C#.Net 创建网页快捷方式的更多相关文章
- (转)Inno Setup入门(四)——为程序创建桌面快捷方式
本文转载自:http://blog.csdn.net/augusdi/article/details/8564810 Icons这一可选段定义所有创建在开始菜单和\或其它位置 (比如桌面) 的快捷方式 ...
- 小技巧(一):将文本文件txt或网页快捷方式固定到win10开始菜单
win10不知道怎么回事不支持将文本文件和网页快捷方式固定到开始菜单 解决方法: 利用cmd 创建一个快捷方式: 路径:cmd /A /C C:\Users\Admin\Desktop\test.t ...
- Ubuntu创建桌面快捷方式
默认情况下,ubuntu会将自动安装的软件快捷方式保存在/usr/share/applications目录下,如果我们要创建桌面快捷方式,只需要右键-复制-桌面 就Ok,如图: 上面的方法是通过系统自 ...
- 手机APP创建桌面快捷方式
预览: 需要权限: <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT& ...
- Windows中创建桌面快捷方式
Windows中创建桌面快捷方式 -------------- -------------- -------------- --------------
- WPF 创建桌面快捷方式
#region 创建桌面快捷方式 string deskTop = System.Environment.GetFolderPath(System.Environment.SpecialFolder. ...
- 解决Inno Setup制作安装包无法创建桌面快捷方式的问题
转自:http://yedward.net/?id=104 昨天想把个java程序做成exe安装软件,然后就去下载了Inno Setup这个软件安装包制作软件,Inno Setup这个软件确实非常好用 ...
- C#创建桌面快捷方式 和 开机启动
/// <summary> /// 创建桌面快捷方式 2010-11-25 /// </summary> p ...
- android 为应用程序创建桌面快捷方式技巧分享
手机装的软件过多,找起来很不方便,所以在主页面有一个快捷方式的话会很不错的,本文将介绍如何实现,需要了解跟多的朋友可以参考下 我们开发一款软件后,如果手机装的软件过多,去翻的话会很难翻的,所以 ...
随机推荐
- UIAlertView[警告框] [代理协议型]UIActionSheet [表单视图][代理协议型]
//// ViewController.h// UIAlertViewAndUIActionSheet//// Created by hehe on 15/9/21.// Copyright ...
- 【学习笔记】【C语言】自增自减
1. 简单使用 ++ 自增运算符.如a++,++a,都等价于a = a+1 --自减运算符.如a--,--a,都等价于a = a-1 5++是错误的,因为5是常量 2. ++a和a++的区别 int ...
- 对索引像素格式的图片进行Setpixel(具有索引像素格式的图像不支持SetPixel)解决方案
最近编写了一个验证码识别软件.其中对png.jpg图片进行二值化处理时,出现了错误:具有索引像素格式的图像不支持SetPixel解决方案.从字面上来看,这说明我对一个具有索引色的图片进行了直接RGB颜 ...
- 杭电ACM2097--Sky数
这题思路很简单,把10,12,16进制数都按位相加,然后进行比较即可. http://acm.hdu.edu.cn/showproblem.php?pid=2097 <span style=&q ...
- Base64加密
实际开发中可能需要使用到可解密的加密方式,例如客户端记住用户的密码,客户端不能记住明文密码,那就需要对明文密码进行加密,然后在表单提交之后先对密码进行解密,在进行MD5加密和数据库中的密码进行比较实现 ...
- 关闭MyEclipse代码编辑器(breadcrumb)工具条
1. 在工具栏上找“Toggle Breadcrumb”按钮,单击使其恢复未选中状态即可 2. 如果找不到这个按钮.通过菜单“Window->Customize Perspective”打开对话 ...
- 使用记事本+CSC编译程序
本次学习主要阐明.NET开发可以不使用VS,也能像Java一样使用命令窗口.但实际意义不大. 诸位看管不必太留意.(仅供留着给公司新人,树(tree)新(new)风(bee)用.) 1.新建一个文本文 ...
- multiple backgrounds 多重背景
语法缩写如下: background : [background-color] | [background-image] | [background-position][/background-siz ...
- 安装ipvsadm时出现下面所示错误,MARK
[root@localhost ipvsadm-1.26]# makemake -C libipvsmake[1]: Entering directory `/usr/local/soft/ipvsa ...
- 全民wifi钓鱼来临----agnes安卓wifi钓鱼神器介绍
断断续续搞了一些无线的东西,从bt5的aircrack-ng的破无线(没怎么成功过)其实EWSA这个用GPU跑还算不错,可惜了我这显卡也只能每秒2500,到用c118在OsmocomBB基础上进行gs ...