TdcShellLink component
Properties Methods |
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).
|
Just point the FileName property to the .lnk file and read the information from other properties:
|
LinkTarget | Points to the file which should be opened on starting s shortcut (on clicking the shortcut icon);
|
Parameters | The command-line parameters for executable file specified by LinkTarget property. (if LinkTarget is an EXE);
|
WorkingDirectory | Working directory for executable file specified in LinkTarget property. (if LinkTarget is an EXE);
|
RunAs | Specifies how the window should be opened: minimized, maximized or in its normal state;
|
IconLocation, IconIndex | Points 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;
|
HotKey | Specifies the key combination which executes a shortcut;
|
LargeIcon, SmallIcon | Read-only properties. Contains the 32x32 and 16x16 icons of shortcut link.
|
|
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.
|
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;
|
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
|