zoukankan      html  css  js  c++  java
  • delphi编程创建桌面快捷方式

    uses ActiveX,ComObj,StdCtrls,ShlObj,FileCtrl;
    procedure TForm1.N2Click(Sender: TObject);
    var
    tmpObject : IUnknown;
    tmpSLink : IShellLink;
    tmpPFile : IPersistFile;
    PIDL : PItemIDList;
    StartupDirectory : array[0..MAX_PATH] of Char;
    StartupFilename : String;
    LinkFilename : WideString;
    begin
    //创建快捷方式到桌面
    StartupFilename :=Application.ExeName;
    tmpObject := CreateComObject(CLSID_ShellLink);//创建建立快捷方式的外壳扩展
    tmpSLink := tmpObject as IShellLink;//取得接口
    tmpPFile := tmpObject as IPersistFile;//用来储存*.lnk文件的接口
    tmpSLink.SetPath(pChar(StartupFilename));//设定所在路径
    tmpSLink.SetWorkingDirectory(pChar(ExtractFilePath(StartupFilename)));//设定工作目录
    SHGetSpecialFolderLocation(0,CSIDL_DESKTOPDIRECTORY,PIDL);//获得桌面的Itemidlist
    tmpSLink.SetDescription(’我的程序的描述);
    tmpSLink.SetIconLocation(Pchar(StartupFilename),0);
    SHGetPathFromIDList(PIDL,StartupDirectory);//获得桌面路径
    LinkFilename := StartupDirectory + ’\我的程序.lnk’;
    tmpPFile.Save(pWChar(LinkFilename),FALSE);//保存*.lnk文件
    end;

  • 相关阅读:
    二分图最大匹配
    Problems about trees
    Hackerrank Going to the Office
    多校题解
    HDU #2966 In case of failure
    K-D Tree
    UOJ #10 pyx的难题
    bzoj 1090 字符串折叠
    uva 1347 旅行
    bzoj 1059 矩阵游戏
  • 原文地址:https://www.cnblogs.com/railgunman/p/1900704.html
Copyright © 2011-2022 走看看