Shellman
asked on
Read Version Info of my EXE
Hi!
I want that the version number of my program is always shown in the title bar of my application. It should be the one from Project Options -> Versions. The build number changes all the time and I don't want to update the Form1.caption by hand.
Is there any variable that contains the version number that I can access in runtime, or any other way how I can access the version number?
Thanks for your answers!
Shellman
I want that the version number of my program is always shown in the title bar of my application. It should be the one from Project Options -> Versions. The build number changes all the time and I don't want to update the Form1.caption by hand.
Is there any variable that contains the version number that I can access in runtime, or any other way how I can access the version number?
Thanks for your answers!
Shellman
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
Thanks for your answer, it works great. I hope it will save some work.
Shellman
Thanks for your answer, it works great. I hope it will save some work.
Shellman
You're welcome!
Thanks for the points.
DaFox
Thanks for the points.
DaFox
or you can also try this function.
function GetAppVersion:string;
var
Size, Size2: DWord;
Pt, Pt2: Pointer;
begin
Size := GetFileVersionInfoSize(PCh ar (ParamStr (0)), Size2);
if Size > 0 then begin
GetMem (Pt, Size);
try
GetFileVersionInfo (PChar (ParamStr (0)), 0, Size, Pt);
VerQueryValue (Pt, '\', Pt2, Size2);
with TVSFixedFileInfo (Pt2^) do begin
Result := IntToStr (HiWord (dwFileVersionMS)) + '.' +
IntToStr (LoWord (dwFileVersionMS)) + '.' +
IntToStr (HiWord (dwFileVersionLS)) + '.' +
IntToStr (LoWord (dwFileVersionLS));
end;
finally
FreeMem (Pt);
end;
end;
end;
function GetAppVersion:string;
var
Size, Size2: DWord;
Pt, Pt2: Pointer;
begin
Size := GetFileVersionInfoSize(PCh
if Size > 0 then begin
GetMem (Pt, Size);
try
GetFileVersionInfo (PChar (ParamStr (0)), 0, Size, Pt);
VerQueryValue (Pt, '\', Pt2, Size2);
with TVSFixedFileInfo (Pt2^) do begin
Result := IntToStr (HiWord (dwFileVersionMS)) + '.' +
IntToStr (LoWord (dwFileVersionMS)) + '.' +
IntToStr (HiWord (dwFileVersionLS)) + '.' +
IntToStr (LoWord (dwFileVersionLS));
end;
finally
FreeMem (Pt);
end;
end;
end;
Type
PVS_FixedFileInfo = ^TVS_FixedFileInfo;
TVS_FixedFileInfo = record
dwSignature : dword;
dwStrucVersion : dword;
dwFileVersionMS : dword;
dwFileVersionLS : dword;
dwProductVersionLS : dword;
dwFileFlagsMask : dword;
dwFileFlags : dword;
dwFileOS : dword;
dwFileType : dword;
dwFileSubtype : dword;
dwFileDateMS : dword;
dwFileDateLS : dword;
end;