【转载】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 为应用程序创建桌面快捷方式技巧分享
手机装的软件过多,找起来很不方便,所以在主页面有一个快捷方式的话会很不错的,本文将介绍如何实现,需要了解跟多的朋友可以参考下 我们开发一款软件后,如果手机装的软件过多,去翻的话会很难翻的,所以 ...
随机推荐
- 【学习笔记】虚拟机安装Mac系统
参考了这篇装的虚拟机 http://jingyan.baidu.com/article/ff411625b9011212e48237b4.html 系统的话可以到远景去找找 安装用工具: http:/ ...
- vs2010工具栏 不显示dx控件
进入命令提示符 跳转到Dev控件安装目录,如目录D:\Program Files (x86)\DevExpress 2010.1\Components\Toolss下, 然后执行命令:ToolboxC ...
- 村田噪声抑制基础教程-第一章 需要EMI静噪滤波器的原因
1-1. 简介 EMI静噪滤波器 (EMIFIL®) 是为电子设备提供电磁噪声抑制的电子元件,配合屏蔽罩和其他保护装置一起使用.这种滤波器仅从通过连线传导的电流中提取并移除引起电磁噪声的元件.第1章说 ...
- 理解 pkg-config 工具
引用了别人的文章:http://www.chenjunlu.com/2011/03/understanding-pkg-config-tool/ 你在 Unix 或 Linux 下开发过软件吗?写完一 ...
- iOS屏幕尺寸和分辨率
iOS平台家族成员主要包括iPhone.iPod Touch和iPad,但是各类设备的分辨率各不相同,目前存在的尺寸主要有: iOS设备的尺寸多种多样,此外,屏幕的分辨率也有多种,总结如下表所示: 其 ...
- NaN属性,isNaN函数
NaN:Not a Number,顾名思义,表示不是一个数字. 可以把 Number 对象设置为该值,来指示其不是数字值. 使用 isNaN() 全局函数来判断一个值是否是 NaN 值 详见 Java ...
- WebApp遇到的一些坑
一.关于js 1. 引用zepto.js时,借用插件swipe时,写的滑动加载,在ios上可以实行滑动加载数据,但是在安卓上,就是不能滑动: 注: 在使用插件的时候,要先注意其兼容性问题. 2. 用j ...
- windows下apache配置https
1.下载带有openSSL的apache安装包,我下载的为apache_2.2.11-win32-x86-openssl-0.9.8i.msi,安装后确认一下bin路径下的openssl.exe,ss ...
- Unity3d 动态批处理的问题
这段时间做unity3d的优化,主要的入手是减少draw call. 1.代码上主要是把一些零碎的同材质的合并成一个大的mesh. 2.减少不必要的全屏后期处理.把摄像机的renderin ...
- php win主机下实现ISAPI_Rewrite伪静态
有的win主机iss不支持 .htaccess 文件, 我在这里指的不是本地 在本地的话用apmserv服务器可以用.htaccess 文件,用apmserv服务器环境配置伪静态可以看 php 伪静态 ...