快捷方式制作
2008-10-27 09:37
246 查看
要创建快捷方式需要用到IWshRuntimeLibrary命名空间,在这里我们要USING一下。并在引用里添加一个COM,windows script host object model。
具体创建如下:
Code
private void CreateShortCut()
{
string mysite = "http://" + iis + "/path/defaut.aspx";
//创建Windows Script Host Shell类
IWshRuntimeLibrary.IWshShell_Class shell = new IWshRuntimeLibrary.IWshShell_ClassClass();
if (this.Context.Parameters["ckFavorites"] == "1")
{
string fav = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites) + "\\××××××××.url";
//定义快捷方式文件
IWshRuntimeLibrary.IWshURLShortcut shortcut = shell.CreateShortcut(fav) as IWshRuntimeLibrary.IWshURLShortcut;
shortcut.TargetPath = mysite;
//保存快捷方式
shortcut.Save();
}
if (this.Context.Parameters["ckDesktop"] == "1")
{
string dsk = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) + "\\××××××××.url";
IWshRuntimeLibrary.IWshURLShortcut shortcut = shell.CreateShortcut(dsk) as IWshRuntimeLibrary.IWshURLShortcut;
shortcut.TargetPath = mysite;
shortcut.Save();
}
}
具体创建如下:
Code
private void CreateShortCut()
{
string mysite = "http://" + iis + "/path/defaut.aspx";
//创建Windows Script Host Shell类
IWshRuntimeLibrary.IWshShell_Class shell = new IWshRuntimeLibrary.IWshShell_ClassClass();
if (this.Context.Parameters["ckFavorites"] == "1")
{
string fav = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites) + "\\××××××××.url";
//定义快捷方式文件
IWshRuntimeLibrary.IWshURLShortcut shortcut = shell.CreateShortcut(fav) as IWshRuntimeLibrary.IWshURLShortcut;
shortcut.TargetPath = mysite;
//保存快捷方式
shortcut.Save();
}
if (this.Context.Parameters["ckDesktop"] == "1")
{
string dsk = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) + "\\××××××××.url";
IWshRuntimeLibrary.IWshURLShortcut shortcut = shell.CreateShortcut(dsk) as IWshRuntimeLibrary.IWshURLShortcut;
shortcut.TargetPath = mysite;
shortcut.Save();
}
}
相关文章推荐
- NSIS制作卸载器时注意事项和如何创建桌面快捷方式
- Ubuntu 启动器/快捷方式/ 制作 (Eclipse为例)
- vs.net应用程序图标以及制作安装程序快捷方式图标设置
- 鹏鹏的Altium Designer快捷方式技巧--库文件的制作
- Jmeter安装教程+Jmeter快捷方式图标制作
- InstallShield中如何制作应用程序的卸载快捷方式
- 如何制作一个网页快捷方式?不简单你杀了我。
- 终极解决:Cab安装包的时候,制作中文快捷方式,用中文编译会报错,用英文做为快捷方式名
- Linux下为可执行shell脚本文件(.sh),制作桌面启动快捷方式
- Winform打包程序制作的快捷方式指向错误的位置(指向安装包文件)
- 解决 Inno Setup 5.5.8 制作安装包 创建桌面快捷方式 问题
- 解决Inno Setup制作安装包无法创建桌面快捷方式的问题
- IOS 制作常用代码的快捷方式
- 用InstallShield制作卸载快捷方式
- HOWTO:InstallShield中如何制作应用程序的卸载快捷方式
- linux的.desktop文件,桌面快捷方式制作
- 解析制作俄罗斯APT组织使用的快捷方式后门文件
- linux图形化应用程序快捷方式制作方法
- Wise Installation制作的安装包添加卸载快捷方式
- .Net程序打包安装与卸载制作 ——怎样创建网页快捷方式(“开始与程序”菜单中)?(七)