I'm reading the value of an INF file, now I need to compare it with the installer version, but when I compile I get an error:
Unknown identifier: CompareVersion
What is wrong?
[Code]
function GetKeyValue(const AKeyName, AFileName, ADefault: string): string;
var
I: Integer;
KeyPos: Integer;
KeyFull: string;
FileLines: TArrayOfString;
begin
Result := ADefault;
if LoadStringsFromFile(AFileName, FileLines) then
begin
KeyFull := AKeyName + '=';
for I := 0 to GetArrayLength(FileLines) - 1 do
begin
FileLines[I] := TrimLeft(FileLines[I]);
KeyPos := Pos(KeyFull, FileLines[I]);
if KeyPos > 0 then
begin
Result := Copy(FileLines[I], KeyPos + Length(AKeyName) + 1, MaxInt);
Break;
end;
end;
end;
end;
var
L2Ver2: TLabel;
procedure DirEditChange(Sender: TObject);
var
FilePath: string;
begin
FilePath := AddBackslash(WizardForm.DirEdit.Text) + 'left4dead2\steam.inf';
L2Ver2.Caption := GetKeyValue('PatchVersion', FilePath, 'N/A');
if (CompareVersion( L2Ver2.Caption, '{#MyAppOldVersion}') = 0) then
begin
...
end
end;
I have the error in this line:
if (CompareVersion( L2Ver2.Caption, '{#MyAppOldVersion}') = 0) then
{#MyAppOldVersion}
is already defined.
This post is related to my previous question: Read an INF file during the Setup.
If anyone can help, I would appreciate.
There's no
CompareVersion
function in Inno Setup.You need to define your own.
Something like:
0
, if the versions are equal.-1
, if theV1
is older than theV2
.1
, if theV1
is newer than theV2
.1.12
is considered newer than1.1
.1.1
is considered the same as1.1.0
.Unit tests: