2009. július 5., vasárnap
Load and read a shortcut to see where it points to
Problem/Question/Abstract:
How to load and read a shortcut to see where it points to
Answer:
procedure GetShellLinkInfo(const LinkFile: WideString; var SLI: TShellLinkInfo);
{Retrieves information on an existing shell link}
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));
{The IShellLink implementer must also support the IPersistFile interface. Get an interface pointer to it}
PF := SL as IPersistFile;
{ Load file into IPersistFile object }
OleCheck(PF.Load(PWideChar(LinkFile), STGM_READ));
{Resolve the link by calling the Resolve interface function}
OleCheck(SL.Resolve(0, SLR_ANY_MATCH or SLR_NO_UI));
{Get all the info}
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;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése