The "IShortCut" interface implements functionality for handling
shortCuts/shellLinks. It is an encapsulation of the Windows standard
"IShellLink" COM object. The functionality is basically the same, but my
interface is (of course) much easier to use. A list of methods and
properties can be found in the IShortCut Reference.
|
type IShortCut = interface (IBasic) ['{00BED963-C78D-11D3-A530-00005A180D69}'];
|
|
There are multiple ways to get an "IShortCut" instance, e.g. loading an
existing shortCut/shellLink file or creating a new one. Besides the in the
following box listed functions you can also use IShellObj.NewShortCut
and IShellObj.LoadShortCut.
|
function LoadShortCut (shortCutFile: string) : IShortCut;
function NewShortCut (path : string ) : IShortCut; overload;
function NewShortCut (sf : TSpecialFolder) : IShortCut; overload;
function NewShortCut (const idList : IIDList ) : IShortCut; overload;
function NewShortCut (const sfi : IShellFolder ) : IShortCut; overload;
function ShortCut (const sli: IShellLink) : IShortCut;
|
|
If the property "ShortCutFileName" is filled with a specific path, you can
call "Save" without any parameters. The property "IsDirty" tells you,
whether the "IShortCut" object was modified. If a dirty object gets
destroyed, changes are saved automatically - but only, if the property
"ShortCutFileName" is filled correctly.
|
property IShortCut.ShortCutFileName : string;
function IShortCut.IsDirty : boolean;
function IShortCut.Save (shortCutFileName : string = '';
tryToResolve : boolean = true) : boolean;
|
|
The following 2 properties have basically the same meaning, only the format
differs. While one represents the shortCut/shellLink target as a file system
path, the other uses an IIDList for that purpose. For non file system
objects you should choose the "IDList" property.
|
property IShortCut.Path : string;
property IShortCut.IDList : IIDList;
LoadShortCut('C:\Notepad.lnk').Path -> 'C:\Windows\Notepad.exe'
|
|
You have easy access to the most important properties of the
shortCut/shellLink:
|
property IShortCut.Description : string;
property IShortCut.Params : string;
property IShortCut.WorkingDir : string;
property IShortCut.HotKey : string;
property IShortCut.ShowCmd : integer;
with NewShortCut('C:\Windows\Notepad.Exe') do begin
WorkingDir := 'C:\Notepad Documents';
ShowCmd := SW_SHOWMAXIMIZED;
Save('C:\Notepad.lnk');
end;
|
|
Each shortCut/shellLink can be combined with a specific icon:
|
property IShortCut.IconPath : string;
property IShortCut.IconIndex : integer;
function IShortCut.SetIcon (iconPath : string;
iconIndex : integer) : boolean;
|
|
The following function returns a complete TWin32FindData structure for the
linked object:
|
property IShortCut.FindData : TWin32FindData;
|
|
The "Resolve" method looks for the linked object and updates the IDList and
the icon, if necessary.
|
function IShortCut.Resolve (parentWnd : cardinal = INVALID_HANDLE_VALUE;
timeOut : word = 3000 ) : boolean;
|
|
The following property gives you access to the Windows standard "IShellLink"
COM object, which represents the current shortCut/shellLink.
|
property IShortCut.IShellLink_ : IShellLink;
|
|