{
uses bolumune asagidaki unit'leri ekleyin:
ShlObj, ComObj, ActiveX, registry
}
type
TShortCutLocation = (slDesktop, slStartMenu, slQuickLaunch);
TShortCutLocations = set of TShortCutLocation;
procedure CreateShortCut(Description, ApplicationPath, StartFolder: string;
Locations: TShortCutLocations);
var
MyObject : IUnknown;
MySLink : IShellLink;
MyPFile : IPersistFile;
Directory : string;
WFileName : WideString;
MyReg : TRegIniFile;
begin
MyObject := CreateComObject(CLSID_ShellLink);
MySLink := MyObject as IShellLink;
MyPFile := MyObject as IPersistFile;
with MySLink do begin
{ Parametreler icin kullanilabilir:
SetArguments(PChar(ApplicationPath));
}
MySLink.SetPath(PChar(ApplicationPath));
SetRelativePath(PChar(StartFolder),0);
SetWorkingDirectory(PChar(StartFolder));
SetDescription(PChar(Description));
SetIconLocation(PChar(ApplicationPath),0);
end;
MyReg := TRegIniFile.Create('Software\MicroSoft\Windows\CurrentVersion\Explorer');
// Desktop'a kisa yol olusturmak icin }
if slDesktop in Locations then
begin
Directory := MyReg.ReadString('Shell Folders','Desktop','');
WFileName := Directory+ '\' + Description + '.lnk';
MyPFile.Save(PWChar(WFileName),False);
end;
//Start Menu icin
if slStartMenu in Locations then
begin
Directory := MyReg.ReadString('Shell Folders','Programs','');
{ Alt Klasörde olusturmak icin:
Directory = Directory + '\KlasorAdi';
CreateDir(Directory);
}
WFileName := Directory+ '\' + Description + '.lnk';
MyPFile.Save(PWChar(WFileName),False);
end;
// QuickLaunch icin
if slQuickLaunch in Locations then
begin
Directory := MyReg.ReadString('Shell Folders','Appdata','');
WFileName := Directory +
'\Microsoft\Internet Explorer\Quick Launch\' +
Description + '.lnk';
MyPFile.Save(PWChar(WFileName),False);
end;
MyReg.Free;
end;
// Kullanimi:
procedure TForm1.Button1Click(Sender: TObject);
begin
// Desktop, Start Menu ve Quick Launch'da olustur
CreateShortCut('Not defteri', 'c:\windows\notepad.exe', 'c:\windows\',
[slDesktop, slStartMenu, slQuickLaunch]);
// Sadece Desktop ve Quick Launch'da olustur
CreateShortCut('Not defteri', 'c:\windows\notepad.exe', 'c:\windows\',
[slDesktop, slQuickLaunch]);
end;