zoukankan      html  css  js  c++  java
  • C#创建一个文件的快捷方式

    您可以使用Interope,在您的项目中引入"Windows Script Host Object Model" COM library。

    然后运行下面的代码:

    using System;
    using System.Runtime.InteropServices;
    using IWshRuntimeLibrary;

    namespace CreateShortcutCOM {
    /// <summary>
    /// This class creates a shortcut with COM interoperability
    /// </summary>
      class ShortcutDemo {
        [STAThread]
        static void Main(string[] args) {
          // Get the app path and filename
          string app = Environment.CurrentDirectory + @"\CreateShortcutCOM.exe";

          try {
            // Create a Windows Script Host Shell class
            IWshShell_Class shell = new IWshShell_ClassClass();
            // Define the shortcut file
            IWshShortcut_Class shortcut = shell.CreateShortcut(app + ".lnk") as IWshShortcut_Class;
            // Set all its properties
            shortcut.Description = "Smart sample of creating shell shortcut";
            shortcut.TargetPath = app;
            shortcut.IconLocation = app + ",0";
            // Save it
            shortcut.Save();
          }
          catch(COMException ex) {
             Console.WriteLine(ex.Message);
          }
        }
      }
    }

  • 相关阅读:
    第六章:单元测试框架unittest
    Jenkins 使用 war包安装时,如果出现报离线错误解决方法
    Appium自动化封装教案
    yaml文件读取(5.1之前与5.1之后对比)
    appium-desktop配置运用方法
    postwoman 配置
    jwt解析
    pytest
    centos安装python3.8
    linux 查找命令
  • 原文地址:https://www.cnblogs.com/flyfish/p/81454.html
Copyright © 2011-2022 走看看