Sign in Join
Wiki copytemporary

Revision 1 of 1, by Trev on 2-16-2020. The page as it is now.

GetCurrentVersion/de

Zurück zur Seite Code Beispiele.

Dieser Artikel beschäftigt sich mit der Windowsprogrammierung.

Die Funktion ermittelt die aktuelle Version des eigenen Programms.

pascal
uses
  Windows, SysUtils, ...;

  ...

function funGetCurrentVersion: string;
var
  lwdVerInfoSize: longword;
  lwdVerValueSize: longword;
  lwdDummy: longword;
  ptrVerInfo: Pointer;
  VersionsInformationen: PVSFixedFileInfo;

begin

  lwdVerInfoSize := GetFileVersionInfoSize(PChar(ParamStr(0)), lwdDummy);
  GetMem(ptrVerInfo, lwdVerInfoSize);
  GetFileVersionInfo(PChar(ParamStr(0)), 0, lwdVerInfoSize, ptrVerInfo);
  VerQueryValue(ptrVerInfo, '\', Pointer(VersionsInformationen), lwdVerValueSize);

  with VersionsInformationen^ do
  begin
    Result := IntToStr(dwFileVersionMS shr 16);
    Result := Result + '.' + IntToStr(dwFileVersionMS and $FFFF);
    Result := Result + '.' + IntToStr(dwFileVersionLS shr 16);
    Result := Result + '.' + IntToStr(dwFileVersionLS and $FFFF);
  end;

  FreeMem(ptrVerInfo, lwdVerInfoSize);

end;

...

From the Free Pascal wiki, page "GetCurrentVersion/de", as it stood on 2020-02-16 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.