I am trying to get the version of my running executable so I know when my application has changed to a new version with new features.
I am using the following code to get the version:
function GetVersaoExe: string;
type
PFFI = ^vs_FixedFileInfo;
var
F : PFFI;
Handle : Dword;
Len : Longint;
Data : Pchar;
Buffer : Pointer;
Tamanho : Dword;
Parquivo: Pchar;
Arquivo : string;
begin
Arquivo := Application.ExeName;
Parquivo := StrAlloc(Length(Arquivo) + 1);
StrPcopy(Parquivo, Arquivo);
Len := GetFileVersionInfoSize(Parquivo, Handle);
ShowMessage(IntToStr(Len));
Result := '';
if Len > 0 then
begin
Data:=StrAlloc(Len+1);
if GetFileVersionInfo(Parquivo,Handle,Len,Data) then
begin
VerQueryValue(Data, '\',Buffer,Tamanho);
F := PFFI(Buffer);
Result := Format('%d.%d.%d.%d',
[HiWord(F^.dwFileVersionMs),
LoWord(F^.dwFileVersionMs),
HiWord(F^.dwFileVersionLs),
Loword(F^.dwFileVersionLs)]
);
end;
StrDispose(Data);
end;
StrDispose(Parquivo);
end;
This returns me the number 4.0.1.1.
The problem is that I've been using this function for a while and it never changes this number, it is always 4.0.1.1, I need a number that will change each time I rebuild the application to know that something has changed since the last build.
I checked about three other ways to get the version number and they all happen to do the same thing.
There is a similiar question on StackOverFlow but I still don't know if it works. I checked this question and tried to use their way but there is another problem. When I import ToolsAPI
in my uses unit to use IOTAProjectOptionsConfigurations
and gives me the following error: Cannot compile unit ToolsAPI
.
At last I tried to solve this last problem but I couldn't.