uses ActiveX, ComObj, Shlobj;procedure CreateShortcut(AFileName, ASaveTo: string); var shlLinkUnk: IUnknown; begin shlLinkUnk := CreateComObject(CLSID_ShellLink); if not Assigned(shlLinkUnk) then raise EOleError.Create('Cannot create CoShellLink.'); OleCheck((shlLinkUnk as IShellLinkA).SetPath(PChar(AFileName))); OleCheck((shlLinkUnk as IPersistFile).Save(StringToOleStr(ASaveTo),false)); end;procedure TForm1.Button1Click(Sender: TObject); begin CreateShortcut('c:\bootlog.txt','d:\bl.lnk'); end;
ActiveX, ComObj, Shlobj;procedure CreateShortcut(AFileName, ASaveTo: string);
var
shlLinkUnk: IUnknown;
begin
shlLinkUnk := CreateComObject(CLSID_ShellLink);
if not Assigned(shlLinkUnk) then
raise EOleError.Create('Cannot create CoShellLink.');
OleCheck((shlLinkUnk as IShellLinkA).SetPath(PChar(AFileName)));
OleCheck((shlLinkUnk as IPersistFile).Save(StringToOleStr(ASaveTo),false));
end;procedure TForm1.Button1Click(Sender: TObject);
begin
CreateShortcut('c:\bootlog.txt','d:\bl.lnk');
end;