uses
ActiveX, ComObj;
procedure GetDocInfo(aFileName:
String; Lines: TStrings);
const
FMTID_SummaryInformation: TGUID = '
{F29F85E0-4FF9-1068-AB91-08002B27B3D9}';
type
TPropSpecArray =
array[0..1000]
of TPropSpec;
PPropSpecArray = ^TPropSpecArray;
TPropVariantArray =
array[0..1000]
of TPropVariant;
PPropVariantArray = ^TPropVariantArray;
var
stgRoot: IStorage;
stgPS: IPropertySetStorage;
stgP: IPropertyStorage;
ps: PPropSpecArray;
pv: PPropVariantArray;
begin
Lines.Clear;
OleCheck(StgOpenStorage(PWideChar(WideString(aFileName)),
nil, STGM_READ
or
STGM_SHARE_EXCLUSIVE,
nil, 0, stgRoot));
stgPS := stgRoot
as IPropertySetStorage;
OleCheck(stgPS.Open(FMTID_SummaryInformation, STGM_READ
or
STGM_SHARE_EXCLUSIVE, stgP));
ps :=
nil;
pv :=
nil;
GetMem(ps, SizeOf(TPropSpecArray));
GetMem(pv, SizeOf(TPropVariantArray));
try
ps[0].ulKind := PRSPEC_PROPID;
ps[0].propid := PIDSI_TITLE;
ps[1].ulKind := PRSPEC_PROPID;
ps[1].propid := PIDSI_COMMENTS;
ps[2].ulKind := PRSPEC_PROPID;
ps[2].propid := PIDSI_AUTHOR;
OleCheck(stgP.ReadMultiple(3, @ps[0], @pv[0]));
Lines.Add('
Titel: ' + pv[0].pszVal);
Lines.Add('
Kommentar: ' + pv[1].pszVal);
Lines.Add('
Autor: ' + pv[2].pszVal);
finally
FreeMem(ps);
FreeMem(pv);
end;
end;