Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Курсовая работа1 / UCcVersionInfo

.pas
Скачиваний:
12
Добавлен:
01.05.2014
Размер:
2 Кб
Скачать
{
  C-like language compiler v0.1.0.485

  12 november 2007

  Copyright (C) 2006, 2007 Igor Krooshch
  rheo.ikro@gmail.com

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
}

unit UCcVersionInfo;

interface

uses
  SysUtils, Classes, Windows;

  procedure FileVersion(const AFileName: string; var LS, MS: cardinal);
  function GetVersionStr: string;

implementation

procedure FileVersion(const AFileName: string; var LS, MS: cardinal);
var
  FileName: string;
  InfoSize, Wnd: DWORD;
  VerBuf: Pointer;
  FI: PVSFixedFileInfo;
  VerSize: DWORD;
begin
  LS := 0;
  MS := 0;
  // GetFileVersionInfo modifies the filename parameter data while parsing.
  // Copy the string const into a local variable to create a writeable copy.
  FileName := AFileName;
  UniqueString(FileName);
  InfoSize := GetFileVersionInfoSize(PChar(FileName), Wnd);
  if InfoSize <> 0 then
  begin
    GetMem(VerBuf, InfoSize);
    try
      if GetFileVersionInfo(PChar(FileName), Wnd, InfoSize, VerBuf) then
        if VerQueryValue(VerBuf, '\', Pointer(FI), VerSize) then begin
          MS := FI.dwFileVersionMS;
          LS := FI.dwFileVersionLS;
        end;
    finally
      FreeMem(VerBuf);
    end;
  end;
end;


function GetVersionStr: string;
var
  ls, ms: Cardinal;
  ls1, ls2, ms2: integer;
begin
  FileVersion(ParamStr(0), ls, ms);
  ls1 := ls shr 16;
  ls2 := (ls shl 16) shr 16;
  ms2 := (ms shl 16) shr 16;
  Result := Format('%d.%d (build %d)', [ls1, ms2, ls2]);
end;


end.
 
Соседние файлы в папке Курсовая работа1