//==============================================================================
//创建一个快捷方式**************************************************************
//==============================================================================
function CreateLinkFile(const Info: LINK_FILE_INFO; const TargetFileName: string=''): boolean;
var OBJ: IUnknown;
    ShellLink: IShellLink;
    PersistFile: IPersistFile;
    wFileName: WideString;
begin
  wFileName := TargetFileName;
  OBJ := CreateComObject(CLSID_SHELLLINK);
  ShellLink := OBJ as IShellLink;
  PersistFile := OBJ as IPersistFile;
  ShellLink.SetPath(Info.FileName);
  ShellLink.SetWorkingDirectory(Info.WorkDirectory);
  ShellLink.SetDescription(Info.Description);
  ShellLink.SetArguments(Info.Arguments);
  ShellLink.SetIconLocation(Info.IconLocation, Info.IconIndex);
  //ShellLink.SetIDList(Info.ItemIDList);
  ShellLink.SetHotkey(Info.HotKey);
  ShellLink.SetShowCmd(Info.ShowState);
  ShellLink.SetRelativePath(Info.RelativePath,0);
  if TargetFileName='' then wFileName:=ChangeFileExt(Info.FileName,'lnk');
  Result := Succeeded(PersistFile.Save(PWChar(wFileName), false));
end;

解决方案 »

  1.   

    type LINK_FILE_INFO = record                                         //快捷方式文件信息数据结构
                            FileName: array[0..MAX_PATH] of char;        //目标文件名
                            WorkDirectory: array[0..MAX_PATH] of char;   //工作目录
                            IconLocation: array[0..MAX_PATH] of char;    //图标文件
                            IconIndex: integer;                          //图标索引
                            Arguments: array[0..MAX_PATH] of char;       //运行参数
                            Description: array[0..255] of char;          //文件描述
                            ItemIDList: PItemIDList;                     //系统IDList,未使用
                            RelativePath: array[0..255] of char;         //相对路径
                            ShowState: integer;                          //运行时的现实状态
                            HotKey: word;                                //热键
                          end;