您的位置:首页 > 其它

快捷方式制作

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();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: