Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Mar : Getting ShortCut (Lnk) Information
| Subject: | Getting ShortCut (Lnk) Information |
| Posted by: | "Andrew Jameson" (conta..@softspotsoftware.com) |
| Date: | Fri, 4 Mar 2005 09:06:16 |
Hi,
I'm using the following code to get shortcut information ... pathing to an
associated exe etc. :
procedure GetShellLinkInfo(LinkFile : WideString; var SLI :
TAJShellLinkInfo);
var
SL : IShellLink;
PF : IPersistFile;
FindData : TWin32FindData;
AStr : array[0..MAX_PATH] of char;
begin
OleCheck(CoCreateInstance(CLSID_ShellLink, nil, CLSCTX_INPROC_SERVER,
IShellLink, SL));
PF := SL as IPersistFile;
OleCheck(PF.Load(PWideChar(LinkFile), STGM_READ));
OleCheck(SL.Resolve(0, SLR_ANY_MATCH or SLR_NO_UI));
with SLI do begin
OleCheck(SL.GetPath (AStr, MAX_PATH, FindData,
SLGP_SHORTPATH));
PathName := AStr;
OleCheck(SL.GetArguments (AStr, MAX_PATH));
Arguments := AStr;
OleCheck(SL.GetDescription (AStr, MAX_PATH));
Description := AStr;
OleCheck(SL.GetWorkingDirectory(AStr, MAX_PATH));
WorkingDirectory := AStr;
OleCheck(SL.GetIconLocation (AStr, MAX_PATH, IconIndex));
IconLocation := AStr;
OleCheck(SL.GetShowCmd(ShowCmd));
OleCheck(SL.GetHotKey (HotKey ));
end; {with}
end; {ShellLinkInfo}
I use it to iterate through all the desktop shortcuts ... it runs fine but
on XP SP2 systems it runs very slowly ... on 98, NT and XP SP1 systems there
is no perceptible delay ... any ideas why it runs so slowly (10 to 20
seconds for ~30 shortcuts) ?
Thanks,
Andrew