zoukankan      html  css  js  c++  java
  • 使用代码创建快捷方式

    使用代码创建一个应用程序的快捷方式, 主要是用了IShellLink这个接口, 调用很简单

    uses
      ShlObj, ComObj, ActiveX;
    
    
    
    {参数说明
    AFile: 执行文件(含全路径)
    AArguments: 启动参数
    ALinkCaption: 快捷方式名称
    ADescription: 快捷方式描述
    ALinkPath: 快捷方式目录}
    procedure CreateLinkFile(AFile, AArguments, ALinkCaption, ADescription: string;
      ALinkPath: String = '');
    var
      nIShellLink: IShellLink;
      nIPFile: IPersistFile;
      nLKFile: string;
      i: integer;
    begin
      if SUCCEEDED(CoInitialize(nil)) then
      Try
        nIShellLink := CreateComObject(CLSID_ShellLink) as IShellLink;
        nIPFile  := nIShellLink as IPersistFile;
    
        if ALinkPath = '' then
          ALinkPath := ExtractFilePath(AFile);
    
        with nIShellLink do
        begin
          SetPath(PChar(AFile)); //执行程序的文件名
          SetDescription(PChar(ADescription)); //提示说明文本
          SetWorkingDirectory(PChar(ExtractFilePath(AFile))); //启动目录
          SetArguments(PChar(AArguments));
        end;
    
        nLKFile := ALinkPath + ALinkCaption + '.lnk';
        if FileExists(nLKFile) then //如果文件名存在,就以数据序号来重新命名一个新的文件名
        begin
          i := 1;
          repeat
            nLKFile := ALinkPath + ALinkCaption + '(' + IntToStr(i)+ ').lnk';
            Inc(i);
          until not FileExists(nLKFile);
        end;
    
        nIPFile.Save(PWChar(WideString(nLKFile)), False);
      finally
        CoUninitialize;
      end;
    end;
  • 相关阅读:
    softmax in pytorch
    python使用xlrd读取excel数据
    redis集群扩容(添加新节点)
    redis集群添加新节点
    重新创建redis集群的注意事项
    在三台服务器,搭建redis三主三从集群
    UI自动化测试工具Airtest/Poco
    单个机器部署redis集群模式(一键部署脚本)
    内置函数二
    内置函数一
  • 原文地址:https://www.cnblogs.com/lzl_17948876/p/3461731.html
Copyright © 2011-2022 走看看