Как узнать автора файла документа
Автор: Asmith
Вот простой пример, подробности в MSDN:
uses ActiveX, ComObj, SysUtils;
function GetSummaryInfAuthor(FileName: TFileName): string;
var
PFileName: PWideChar;
Storage: IStorage;
PropSetStg: IPropertySetStorage;
PropStg: IPropertyStorage;
ps: PROPSPEC;
pv: PROPVARIANT;
const
FMTID_SummaryInformation: TGUID = '{F29F85E0-4FF9-1068-AB91-08002B27B3D9}';
begin
PFileName := StringToOleStr(FileName);
try
// Open compound storage
OleCheck(StgOpenStorage(PFileName, nil,
STGM_DIRECT or STGM_READ or STGM_SHARE_EXCLUSIVE, nil, 0, Storage));
finally
SysFreeString(PFileName);
end;
// Summary information is in a stream under the root storage
PropSetStg := Storage as IPropertySetStorage;
// Get the IPropertyStorage
OleCheck(PropSetStg.Open(FMTID_SummaryInformation,
STGM_DIRECT or STGM_READ or STGM_SHARE_EXCLUSIVE, PropStg));
// We want the author property value
ps.ulKind := PRSPEC_PROPID;
ps.propid := PIDSI_AUTHOR;
// Read this property
PropStg.ReadMultiple(1, @ps, @pv);
Result := pv.pszVal;
end;
|
|