You are on page 1of 1

procedure TFormPrinc.

CriaAtalho(PFileAtalho : String);
var
IObject : IUnknown;
ISLink : IShellLink;
IPFile : IPersistFile;
PIDL : PItemIDList;
InFolder : array[0..MAX_PATH] of Char;
TargetName : String;
LinkName : WideString;
begin
TargetName := RFileName;
IObject := CreateComObject(CLSID_ShellLink) ;
ISLink := IObject as IShellLink;
IPFile := IObject as IPersistFile;
with ISLink do
begin
SetPath(pChar(TargetName)) ;
SetWorkingDirectory(pChar(ExtractFilePath(TargetName))) ;
end;
LinkName := PFileAtalho;
IPFile.Save(PWChar(LinkName), false) ;
end;
procedure TFormPrinc.ReplaceVarShortCut;
begin
RShortCut := StringReplace(RShortCut, '%UserProfile%',
GetEnvironmentVariableUTF8('UserProfile') + '\', [rfReplaceAll]);
RShortCut := StringReplace(RShortCut, '%ProgramFiles%',
GetEnvironmentVariableUTF8('ProgramFiles'), [rfReplaceAll]);
end;

You might also like