Inno Setup, unfortunately, does not check file version before checking if the file is locked. It should, imho. Because the file won't get installed in the end, if it has the same version.
Anyway, you can implement the check yourself, using the Check parameter;
[Files]
Source: "ctrlserversvc3.exe"; DestDir: "{code:GetInstallDir|Program}"; \
Check: IsNewer('{#GetFileVersion("ctrlserversvc3.exe")}')
[Code]
procedure CutVersionPart(var VersionString: string; var VersionPart: Word);
var
P: Integer;
begin
P := Pos('.', VersionString);
if P > 0 then
begin
VersionPart := StrToIntDef(Copy(VersionString, 1, P - 1), 0);
Delete(VersionString, 1, P);
end
else
begin
VersionPart := StrToIntDef(VersionString, 0);
VersionString := '';
end;
end;
function IsNewer(InstalledVersion: string): Boolean;
var
Filename: string;
ExistingMS, ExistingLS: Cardinal;
ExistingMajor, ExistingMinor, ExistingRev, ExistingBuild: Cardinal;
InstalledMajor, InstalledMinor, InstalledRev, InstalledBuild: Word;
begin
Filename := ExpandConstant(CurrentFilename);
Log(Format('Checking if %s should be installed', [Filename]));
if not FileExists(Filename) then
begin
Log(Format('File %s does not exist yet, allowing installation', [FileName]));
Result := True;
end
else
if not GetVersionNumbers(FileName, ExistingMS, ExistingLS) then
begin
Log(Format('Cannot retrieve version of existing file %s, allowing installation',
[FileName]));
Result := True;
end
else
begin
ExistingMajor := ExistingMS shr 16;
ExistingMinor := ExistingMS and $FFFF;
ExistingRev := ExistingLS shr 16;
ExistingBuild := ExistingLS and $FFFF;
Log(Format('Existing file %s version: %d.%d.%d.%d',
[FileName, ExistingMajor, ExistingMinor, ExistingRev, ExistingBuild]));
Log(Format('Installing version: %s', [InstalledVersion]));
CutVersionPart(InstalledVersion, InstalledMajor);
CutVersionPart(InstalledVersion, InstalledMinor);
CutVersionPart(InstalledVersion, InstalledRev);
CutVersionPart(InstalledVersion, InstalledBuild);
Log(Format('Installing version: %d.%d.%d.%d',
[InstalledMajor, InstalledMinor, InstalledRev, InstalledBuild]));
if (InstalledMajor > ExistingMajor) or
((InstalledMajor = ExistingMajor) and (InstalledMinor > ExistingMinor)) or
((InstalledMajor = ExistingMajor) and (InstalledMinor = ExistingMinor) and
(InstalledRev > ExistingRev)) then
begin
Log('Installing file that is newer than existing file, ' +
'allowing installation.');
Result := True;
end
else
begin
Log('Installing file that is same or older than existing file, ' +
'skipping installation.');
Result := False;
end;
end;
end;