uses ShlObj, ActiveX, ComObj;
procedure CreateShortCut(SourceFileFullName: string;
DestFileFullName: WideString);
var
MyObject : IUnknown;
MySLink : IShellLink;
MyPFile : IPersistFile;
begin
MyObject := CreateComObject(CLSID_ShellLink);
MySLink := MyObject as IShellLink;
MyPFile := MyObject as IPersistFile;
with MySLinkdo
begin
SetPath(PChar(SourceFileFullName));
SetWorkingDirectory(PChar(ExtractFilePath(SourceFileFullName)));
end;
MyPFile.Save(PWChar(DestFileFullName), False);
end;
使用:
CreateShortCut(Application.ExeName, 'c:/windows/desktop/MyProgram.lnk');