当前位置:编程学习 > C#/ASP.NET >>

asp.net生成桌面快捷方式

用C#代码实现 生成桌面快捷方式 能设置图标的
答案:导入COM组件Windows Script Host Object Model
using IWshRuntimeLibrary;


WshShell shell = new WshShell();
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(
            Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) +
            "\\" + "Allen's Application.lnk"
            );
shortcut.TargetPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
shortcut.WorkingDirectory = System.Environment.CurrentDirectory;
shortcut.WindowStyle = 1;
shortcut.Description = "Launch Allen's Application";
shortcut.IconLocation = System.Environment.SystemDirectory + "\\" + "shell32.dll, 165";
shortcut.Save();


注意倒数第二行:shortcut.IconLocation就是指定的图标

上一个:ASP。NET配置 连接数据库问题
下一个:ASP.NET向事件传递参数

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,