uses ShlObj, ComObj,
ActiveX;
function ReadLnkFile(
const LnkFileName:
String;
out Path, Arguments, WorkingDirectory, Description:
String;
out HotKey: Word;
out ShowCmd: Integer;
out IconPath:
String;
out IconIndex: Integer): Boolean;
var
ShellLink: IShellLink;
PersistFile: IPersistFile;
FileInfo: TWin32FindData;
begin
Result:=False;
if SUCCEEDED(CoCreateInstance(CLSID_ShellLink,
nil, CLSCTX_INPROC_SERVER, IShellLink, ShellLink))
then
begin
PersistFile := ShellLink
as IPersistFile;
if SUCCEEDED(PersistFile.Load(StringToOleStr(LnkFileName), STGM_READ))
then
with ShellLink
do
begin
SetLength(Path, MAX_PATH + 1);
if SUCCEEDED(GetPath(PChar(Path), MAX_PATH, FileInfo, SLR_ANY_MATCH))
then
begin
Path := PChar(Path);
Result := True;
SetLength(Arguments, MAX_PATH + 1);
GetArguments(PChar(Arguments), MAX_PATH);
Arguments := PChar(Arguments);
SetLength(WorkingDirectory, MAX_PATH + 1);
GetWorkingDirectory(PChar(WorkingDirectory), MAX_PATH);
WorkingDirectory := PChar(WorkingDirectory);
SetLength(Description, MAX_PATH + 1);
GetDescription(PChar(Description), MAX_PATH);
Description := PChar(Description);
GetHotkey(HotKey);
GetShowCmd(ShowCmd);
SetLength(IconPath, MAX_PATH + 1);
GetIconLocation(PChar(IconPath), MAX_PATH, IconIndex);
IconPath := PChar(IconPath);
if IconPath = '
'
then
IconPath := Path;
end
else
Path := '
';
end;
end;
end;