Sayfayı Yazdır | Pencereyi Kapat


Desktop, Quick Launch veya Start Menu'de kisayol

Kategori: DELPHI - 7
Eklenme Tarihi: 27 Haziran 2005
Zaman: 18 Mayıs 2012 22:40
Samanalevi Netkafe - http://www.samanalevi.com/bilgisayaroku/115.Desktop_Quick_Launch_veya_Start_Menude_kisayol.html

Desktop, Quick Launch veya Start Menu'de kisa yol yaratmak
{
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;

DELPHI - 7


Sayfayı Yazdır | Pencereyi Kapat 

http://www.samanalevi.com