zoukankan      html  css  js  c++  java
  • 用C# 创建快捷方式

     C# 创建快捷方式 以下代码在2.0,3.0,3.5 下都可以正常运行,在4.0在报错。

    不知道那为仁兄知道在4.0下创建快捷方式。

    选择 COM 选项卡并选择 Windows Script Host Object Model
    using IWshRuntimeLibrary;

    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string DesktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);//得到桌面文件夹 
                WshShell shell = new WshShell();

                IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(DesktopPath + "\\自动创建+.lnk");
                shortcut.TargetPath = @"%HOMEDRIVE%/Program Files\Internet Explorer\IEXPLORE.EXE";
                shortcut.Arguments = "http://www.baidu.com";// 参数 
                shortcut.Description = "快捷链接到网站";
                shortcut.WorkingDirectory = "E:\\Publish Web Site\\clcs";//程序所在文件夹,在快捷方式图标点击右键可以看到此属性 
                shortcut.IconLocation = @"%HOMEDRIVE%/Program Files\Internet Explorer\IEXPLORE.EXE, 0";//图标 
                shortcut.Hotkey = "CTRL+SHIFT+Z";//热键 
                shortcut.WindowStyle = 1;
                shortcut.Save();

            }
        }
    }

    作者:罗敏贵
    邮箱:minguiluo@163.com
    QQ群:34178394 建群 主要是寻找志同道合的人士一起学习和讨论自己的所学所思
    出处:http://luomingui.cnblogs.com/
    说明:专注于微软平台项目架构、熟悉设计模式、架构设计、敏捷个人和项目管理。现主要从事WinForm、ASP.NET、等方面的项目开发、架构、管理工作。文章为作者平时里的思考和练习,可能有不当之处,请博客园的园友们多提宝贵意见。
    知识共享许可协议本作品采用知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议进行许可。

  • 相关阅读:
    JSP学习-10-EL表达式
    深入浅出Mybatis(一)
    第10章—开启事务
    第09章—使用Lombok插件
    第08章—整合Spring Data JPA
    第06章—热部署
    第05章—Swagger2打造在线接口文档
    第03章—打造RESTful风格API
    第04章—整合Mybatis
    第01章—快速构建
  • 原文地址:https://www.cnblogs.com/luomingui/p/2185943.html
Copyright © 2011-2022 走看看