zoukankan      html  css  js  c++  java
  • 创建应用程序快捷方式

    实现效果:

      

    知识运用:

      COM组件Windows Script Host Object Model

      注意:拓展名为lnk  非 Ink //两个是不同的 写成大写的就明白了  :LNK    INK

          小写几乎没有区别  (为此每次运行都会报错  查了一大堆资料都没解决 注意!注意!)

    实现代码:

            private void button2_Click(object sender, EventArgs e)
            {
                if (textBox1.Text.Length == 0)
                { MessageBox.Show("请选择应用程序"); }
                else
                {
                    string dtpath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\short.lnk";
                    string dtpath2 = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\自定义\short2.lnk";
                    string bp = Directory.GetParent(dtpath2).FullName;
                    WshShell ws = new WshShell();                    //创建WshShell对象
                    if (!Directory.Exists(bp))                      //目录不存在
                        Directory.CreateDirectory(bp);
                    IWshShortcut iw = (IWshShortcut)ws.CreateShortcut(dtpath);
                    iw.TargetPath = textBox1.Text;                  //目的指向
                    iw.Description = "这是描述说明的内容";
                    iw.IconLocation = textBox1.Text;                //加载图标的位置
                    iw.Save();
                    IWshShortcut iw2 = (IWshShortcut)ws.CreateShortcut(dtpath2);
                    iw2.TargetPath = textBox1.Text;
                    iw2.Description = textBox1.Text;
                    iw2.IconLocation = textBox1.Text;
                    iw2.Save();
                    MessageBox.Show("指定图标已经创建成功!");
                }
            }
    

      

  • 相关阅读:
    阿里云 ssl 证书 免费申请
    重启aliyun esc 需要重新启动redis
    SSL证书部署
    前端性能优化--合并请求
    npm 镜像修改
    google 浏览器插件安装
    离线安装.NET Framework 3.5
    A new session could not be created. (Original error: Could not find a connected Android device.)
    error: device unauthorized.
    pip 批量安装包
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10325216.html
Copyright © 2011-2022 走看看