CPB Mailing List

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BCB3] Access to version numbering at runtime?



> I would like very much to use the project version numbering at runtime in my
> programs.  I would perhaps display this information in my AboutBox, etc...
> 
> Does anyone know how I can access this version info?
> 
> 
> regards,
> 

Bob, BCB3 (like Delphi) compiler put your project version numbering (and the 
rest of version information) in a version resource in your application exe, so 
you just must use some API functions:

GetFileVersionInfoSize
GetFileVersionInfo
VerQueryValue

to read from version resource.

Below I show you an ObjectPascal (I use an AboutBox form designed in 
Delphi) function that make an string with full version number from version 
resource.

Best regards 

(*********************************)
function GetAppVersion: string;
var
  dwHandle,
  dwLen : DWord;
  lpData : Pointer;
  lpBuffer : PChar;
  uLen : UInt;
begin
  Result := '';
  dwLen := GetFileVersionInfoSize(PChar(Application.ExeName), dwHandle);
  if dwLen <> 0 then begin
    GetMem(lpData, dwLen);
    if GetFileVersionInfo(PChar(Application.ExeName), dwHandle, dwLen, lpData)
    then begin
      if VerQueryValue(lpData, '\', Pointer(lpBuffer), uLen) then
        Result :=
          IntToStr(HiWord(PVSFixedFileInfo(lpBuffer)^.dwFileVersionMS))+'.'+
          IntToStr(LoWord(PVSFixedFileInfo(lpBuffer)^.dwFileVersionMS))+'.'+
          IntToStr(HiWord(PVSFixedFileInfo(lpBuffer)^.dwFileVersionLS))+'.'+
          IntToStr(LoWord(PVSFixedFileInfo(lpBuffer)^.dwFileVersionLS));
    end;
    FreeMem(lpData, dwLen);
  end;
end;
(*********************************)


(*********************************************)
(* Lic. Jorge Luis De Armas García           *)
(* Subdirector of Development and Technology *)
(* Cuban Neuroscience Center                 *)
(* Apartado 6880, La Habana, Cuba            *)
(* e-mail: dearmas@cneuro.edu.cu             *)
(*********************************************)


W Komornicki's Home Page | Main Index | Thread Index