Как создать ShortCut файл (.LNK)?

Материал из DRKB

Как создать ShortCut файл (.LNK)?[править | править код]

uses ShlObj, ActiveX, ComObj;

procedure CreateShortCut(ShortCutName, Parameters, FileName: string);
var ShellObject: IUnknown;
  ShellLink: IShellLink;
  PersistFile: IPersistFile;
  FName: WideString;
begin
  ShellObject := CreateComObject(CLSID_ShellLink);
  ShellLink := ShellObject as IShellLink;
  PersistFile := ShellObject as IPersistFile;
  with ShellLink do
  begin
    SetArguments(PChar(Parameters));
    SetPath(PChar(FileName));
    SetWorkingDirectory(PChar(ExtractFilePath(FileName)));
    FName := ShortCutName;
    PersistFile.Save(PWChar(FName), False);
  end;
end;


Author: Vit (www.delphist.com, www.drkb.ru, www.unihighlighter.com, www.nevzorov.org)
Source: Взято с Vingrad.ru http://forum.vingrad.ru
ID: 01748