Mega Code Archive

 
Categories / Delphi / System
 

Başlat menusune ve masaüstüne kısayol ekleme

{Borland sitesinden alınmıştır. Hepimizin ihtiyacı olabilir.} unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} uses ShlObj, ActiveX, ComObj, Registry; procedure TForm1.Button1Click(Sender: TObject); var MyObject : IUnknown; MySLink : IShellLink; MyPFile : IPersistFile; FileName : String; Directory : String; WFileName : WideString; MyReg : TRegIniFile; begin MyObject := CreateComObject(CLSID_ShellLink); MySLink := MyObject as IShellLink; MyPFile := MyObject as IPersistFile; FileName := 'NOTEPAD.EXE'; with MySLink do begin SetArguments('C:\AUTOEXEC.BAT'); SetPath(PChar(FileName)); SetWorkingDirectory(PChar(ExtractFilePath(FileName))); end; MyReg := TRegIniFile.Create( 'Software\MicroSoft\Windows\CurrentVersion\Explorer'); // Use the next line of code to put the shortcut on your desktop Directory := MyReg.ReadString('Shell Folders','Desktop',''); // Use the next three lines to put the shortcut on your start menu // Directory := MyReg.ReadString('Shell Folders','Start Menu','')+ // '\Whoa!'; // CreateDir(Directory); WFileName := Directory+'\FooBar.lnk'; MyPFile.Save(PWChar(WFileName),False); MyReg.Free; end; end.