zoukankan      html  css  js  c++  java
  • 使用 Windows Scripting Host 中的 WshShortcut 获取快捷方式的信息

    Windows Scripting Host 为我们提供了一个 WshShortcut 对象,可以使用此对象来创建快捷方式或获取快捷方式的信息

    WshShortcut 有以下属性:
    TargetPath:获取或设置快捷方式指向的目标文件的路径
    FullName:获取或设置快捷方式的路径
    Description:获取或设置快捷方式的说明
    IconLocation:获取或设置快捷方式图标的位置
    WindowStyle:获取或设置启动目标程序时所使用的窗口样式
    HotKey:获取或设置用于启动目标程序的热键,只热键只能激活 WINDOWS 桌面和开始菜单中的快捷方式
    WorkingDirectory:获取或设置目标程序的工作目录
    Arguments:获取一个 WshArgument 对象的集合

    WshShortcut 对象还有一个 Save 方法,用来保存快捷方式

    不能直接 new 一个 WshShortcut 对象,需要使用 WshShell 对象的 CreateShortcut 方法:

    WshShell shell = new WshShell();
    WshShortcut link = shell.CreateShortcut("path"); // 如果指定的路径存在,则使用这此信息来创建一个 WshShortcut 对象
    string targetPath = link.TargetPath; // 获取信息

    link.Description = "使用程序设置的说明";
    link.Save(); // 保存信息

    如果需要在 .NET 中使用的话,需要在 COM 活页中引用 “Windows Scripting Host Object Model” 组件
  • 相关阅读:
    Linux YUM (Yellowdog Updater, Modified) Commands for Package Management
    awk命令例子详解
    sed命令例子详解
    浅谈XX系统跨平台迁移(测试环境)
    Postgres常用命令之增、删、改、查
    Postgres主备切换
    Postgres配置主从流复制
    Crontab定时任务
    GIL全局锁测试
    python try exception finally记录
  • 原文地址:https://www.cnblogs.com/kuku/p/1151504.html
Copyright © 2011-2022 走看看