shelllink TdcShellLink component
Properties Methods
Return to Introduction  Previous page  Next page
Overview
The dcShellLink component lets you quickly and easily create the shell links (also known as shortcuts) to files and folders (in any location) and read the information from shorcut files (.lnk).  

How to read the information from shortcut ?
Just point the FileName property to the .lnk file and read the information from other properties:  
LinkTargetPoints to the file which should be opened on starting s shortcut (on clicking the shortcut icon);  
ParametersThe command-line parameters for executable file specified by LinkTarget property. (if LinkTarget is an EXE);  
WorkingDirectoryWorking directory for executable file specified in LinkTarget property. (if LinkTarget is an EXE);  
RunAsSpecifies how the window should be opened: minimized, maximized or in its normal state;  
IconLocation, IconIndexPoints the location to icon file or another file which contains the icon resources. IconIndex property specifies the resource index, if IconLocation is an EXE or DLL;  
HotKeySpecifies the key combination which executes a shortcut;  
LargeIcon, SmallIconRead-only properties. Contains the 32x32 and 16x16 icons of shortcut link.  
 
tip The FILENAME property works either at run- and design-time, so you can play with dcShellLink component, pointing the .lnk file at design-time. After specifyng the FILENAME, all other properties will be filled with information about the shortcut.  

How to create the shell link (shortcut file) ?
To create a shortcut you must specify the shortcut information to according properties and call SaveToFile(FileName) method, where the FileName is the name of shortcut. Function returs False when it fails.  
 
For example, you would like to create the shell link, which points to your current executable file + want to specify the icon #4 from shell32.dll file.  
procedure TForm1.Button1Click(Sender: TObject);  
begin  
  dcShellLink1.LinkTarget := Application.ExeName;  
 
  // next two lines will set icon #4 from shell32.dll  
  dcShellLink1.IconLocation := 'shell32.dll';  
  dcShellLink1.IconIndex := 4;  
 
  // saving to Test.lnk file  
  dcShellLink1.SaveToFile('c:\Test.lnk');  
end;  

How to delete the shell link (shortcut file) ?
Shell links (also known as shortcuts) is usual files, with .LNK extension. To remove a shortcuts - just delete them using standard routines, such like DeleteFile…  
sIU/QH/K+!