Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  3 840

•  TDictionary Custom Sort  5 943

•  Fast Watermark Sources  5 736

•  3D Designer  8 536

•  Sik Screen Capture  6 079

•  Patch Maker  6 512

•  Айболит (remote control)  6 500

•  ListBox Drag & Drop  5 361

•  Доска для игры Реверси  95 142

•  Графические эффекты  6 711

•  Рисование по маске  5 863

•  Перетаскивание изображений  4 893

•  Canvas Drawing  5 266

•  Рисование Луны  4 994

•  Поворот изображения  4 537

•  Рисование стержней  3 211

•  Paint on Shape  2 456

•  Генератор кроссвордов  3 339

•  Головоломка Paletto  2 646

•  Теорема Монжа об окружностях  3 438

•  Пазл Numbrix  2 273

•  Заборы и коммивояжеры  2 935

•  Игра HIP  1 901

•  Игра Go (Го)  1 817

•  Симулятор лифта  2 156

•  Программа укладки плитки  1 882

•  Генератор лабиринта  2 321

•  Проверка числового ввода  2 010

•  HEX View  2 328

•  Физический маятник  1 983

 
скрыть

  Форум  

Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Как прочитать или изменить свойства Word документа 2



{
 Read MS Word properties via Structured Storage.
 by Serhiy Perevoznyk
}
uses
  ComObj, ActiveX;

const
  FmtID_SummaryInformation: TGUID =
  '{F29F85E0-4FF9-1068-AB91-08002B27B3D9}';

function FileTimeToDateTimeStr(F: TFileTime): string;
var
  LocalFileTime: TFileTime;
  SystemTime: TSystemTime;
  DateTime: TDateTime;
begin
  if Comp(F) = 0 then
    Result := '-'
  else
  begin
    FileTimeToLocalFileTime(F, LocalFileTime);
    FileTimeToSystemTime(LocalFileTime, SystemTime);
    with SystemTime do
      DateTime := EncodeDate(wYear, wMonth, wDay) +
        EncodeTime(wHour, wMinute, wSecond, wMilliseconds);
    Result := DateTimeToStr(DateTime);
  end;
end;

function GetDocInfo(const FileName: WideString): string;
var
  I: Integer;
  PropSetStg: IPropertySetStorage;
  PropSpec: array[2..19] of TPropSpec;
  PropStg: IPropertyStorage;
  PropVariant: array[2..19] of TPropVariant;
  Rslt: HResult;
  S: string;
  Stg: IStorage;
begin
  Result := '';
  try
    OleCheck(StgOpenStorage(PWideChar(FileName), nil, STGM_READ or
      STGM_SHARE_DENY_WRITE,
      nil, 0, Stg));
    PropSetStg := Stg as IPropertySetStorage;
    OleCheck(PropSetStg.Open(FmtID_SummaryInformation,
      STGM_READ or STGM_SHARE_EXCLUSIVE, PropStg));
    for I := 2 to 19 do
    begin
      PropSpec[I].ulKind := PRSPEC_PROPID;
      PropSpec[I].PropID := I;
    end;
    Rslt := PropStg.ReadMultiple(18, @PropSpec, @PropVariant);
    OleCheck(Rslt);
    if Rslt <> S_FALSE then
      for I := 2 to 19 do
      begin
        S := '';
        if PropVariant[I].vt = VT_LPSTR then
          if Assigned(PropVariant[I].pszVal) then
            S := PropVariant[I].pszVal;
        case I of
          2: S := Format('Title: %s', [S]);
          3: S := Format('Subject: %s', [S]);
          4: S := Format('Author: %s', [S]);
          5: S := Format('Keywords: %s', [S]);
          6: S := Format('Comments: %s', [S]);
          7: S := Format('Template: %s', [S]);
          8: S := Format('Last saved by: %s', [S]);
          9: S := Format('Revision number: %s', [S]);
          10: S := Format('Total editing time: %g sec',
              [Comp(PropVariant[I].filetime) / 1.0E9]);
          11: S := Format('Last printed: %s',
              [FileTimeToDateTimeStr(PropVariant[I].filetime)]);
          12: S := Format('Create time/date: %s',
              [FileTimeToDateTimeStr(PropVariant[I].filetime)]);
          13: S := Format('Last saved time/date: %s',
              [FileTimeToDateTimeStr(PropVariant[I].filetime)]);
          14: S := Format('Number of pages: %d', [PropVariant[I].lVal]);
          15: S := Format('Number of words: %d', [PropVariant[I].lVal]);
          16: S := Format('Number of characters: %d',
              [PropVariant[I].lVal]);
          17: ; // thumbnail
          18: S := Format('Name of creating application: %s', [S]);
          19: S := Format('Security: %.8x', [PropVariant[I].lVal]);
        end;
        if S <> '' then
          Result := Result + S + #13;
      end;
  finally
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if Opendialog1.Execute then
    ShowMessage(GetDocInfo(opendialog1.FileName));
end;




Похожие по теме исходники

Circle Word Wrap

Word List 1.5

Word Search in Text

Конвертер Word - HTML

 

Create document in Word

Golden Passwords

Work with Word and Excel

Grid Word Highlight

 



Copyright © 2004-2025 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте