【转载】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 为应用程序创建桌面快捷方式技巧分享
手机装的软件过多,找起来很不方便,所以在主页面有一个快捷方式的话会很不错的,本文将介绍如何实现,需要了解跟多的朋友可以参考下 我们开发一款软件后,如果手机装的软件过多,去翻的话会很难翻的,所以 ...
随机推荐
- c#扩展方法-摘自msdn
扩展方法使你能够向现有类型“添加”方法,而无需创建新的派生类型.重新编译或以其他方式修改原始类型. 扩展方法是一种特殊的静态方法,但可以像扩展类型上的实例方法一样进行调用. 对于用 C# 和 Vis ...
- align=absMiddle属性设置
AbsBottom 图像的下边缘与同一行中最大元素的下边缘对齐.AbsMiddle 图像的中间与同一行中最大元素的中间对齐.Baseline 图像的下边缘与第一行文本的下边缘对齐.Bottom 图像的 ...
- Mysql多表查询(两张独立表,一张关系表)
一.数据库设计 1.三个数据表长这样 其中user表记录用户信息,cat主要记录男女性别,mete表是用户id和性别id的对应关系 2.具体数据如下 二.查询目标 查询出所有性别为“男”的 ...
- java 反射的踩的一个坑
今天工作的时候用到了一个反射.其业务简单描述为:系统启动时将需要定时调用的方法签名保存到数据库中,开启线程定时从数据库中读取对应的方法签名,通过反射生成实例后调用方法.完成一定的定时任务. 写到的方法 ...
- SequoiaDB 1.5 版本发布
SequoiaDB 1.5 – 2013.11.13 新特性 1. 新增聚合特性,API实现 GROUPBY, MAX 等功能: 2. 全新改版的Web管理界面: 3. 提供C#语言 ...
- php读取html并截取字符串
一般php采集代码能用的到,这里只是简单的实现代码. <?php $title='脚本学堂'; $hello='jbxue.com!'; $file=file_get_contents('htt ...
- ios 录音
http://code4app.com/ios/%E5%BD%95%E9%9F%B3%E5%92%8C%E6%92%AD%E6%94%BE/51ba821b6803fa6901000000
- smarty框架块函数
块函数的形式是这样的:{func} .. {/func}.换句话说,它们被封闭在一个模板区域内,然后对该区域的内容进行操作.默认地,你的函数实现会被Smarty调用两次:一次是在开始标签,另一次是在闭 ...
- ORACLE AWR 和 ASH
一.关于ASH 我们都知道,用户在 ORACLE 数据库中执行操作时,必然要创建相应的连接和会话, 其中,所有当前的会话信息都保存在动态性能视图 V$SESSION 中,通过该视图,DBA 可 以查看 ...
- Ztack学习笔记(3)-系统启动分析
一 系统启动 //OSAL.cvoid osal_start_system( void ) { #if !defined ( ZBIT ) && !defined ( UBIT ) f ...