Inno Setup 6.1의 새로운 "버전"기능을 사용하여 스크립트를 더 간단하게 만들 수 있습니까?
Nov 17 2020
스크립트에 버전 번호로 작업하는 여러 위치가 있습니다.
시나리오 1
#define AppVerText() \ GetVersionComponents(SourceDir + '\Meeting Schedule Assistant.exe', \ Local[0], Local[1], Local[2], Local[3]), \ Str(Local[0]) + "." + Str(Local[1]) + "." + Str(Local[2])
시나리오 2
{ Is the installed version at least 14.14 ? } Result := (Major < 14) or ((Major = 14) and ((Minor < 14) or ((Minor = 14) and ((Bld < 26429) or ((Bld = 26429) and (Rbld < 3)))))); if (Result) then
다양한 값이 레지스트리 키에서 추출되었습니다.
시나리오 3
{ Check Windows Version } WindowsVersion := GetWindowsVersion; Log(Format('Windows Version: %x', [WindowsVersion])); (* Windows must be Win 7 SP1 (6.1.7601), Win 8.1 (6.3.9200) or higher, eg: Win 10 (10.0.10240) See: http://www.jrsoftware.org/ishelp/index.php?topic=winvernotes Microsoft .Net Framework 4.6.2 will only work with these operating systems. *) if (WindowsVersion < MakeVersion(6, 1, 7601)) or ((WindowsVersion >= MakeVersion(6, 2, 0)) and (WindowsVersion < MakeVersion(6, 3, 0))) then begin MsgBox(SetupMessage(msgWindowsVersionNotSupported), mbError, MB_OK); Result := False; end;
전화 :
function MakeVersion(Major, Minor, Build: Cardinal): Cardinal; begin Result := (Major shl 24) + (Minor shl 16) + Build; end;
Inno Setup 6.1에 도입 된 새로운 "버전"Pascal 기능 등을 사용할 수 있는지 궁금했습니다.
답변
1 MartinPrikryl Nov 17 2020 at 16:24
ComparePackedVersion함수 를 사용할 수 있습니다 (와 함께 PackVersionComponents) :
Result :=
(ComparePackedVersion(
PackVersionComponents(Major, Minor, Bld, Rbld),
PackVersionComponents(14, 14, 26429, 3)) < 0);
코드 길이 측면에서별로 개선되지 않았습니다. 그러나 오류가 발생하기 쉽고 이해하기 쉽습니다.
나는 포장 된 버전 번호를 직접 비교하는 것이 실제로 안전하다고 생각합니다 (적어도 주 버전이 2 ^ 15보다 높지 않은 경우). 비록 PackVersionComponents
스타일을 장려하는.
Result :=
(PackVersionComponents(Major, Minor, Bld, Rbld) <
PackVersionComponents(14, 14, 26429, 3));
관련 질문 : Inno Setup에서 버전 문자열 비교
Windows 버전 테스트의 경우 다음과 결합 할 수 있습니다 GetWindowsVersionEx.
GetWindowsVersionEx(WinVer);
WinVerPacked := PackVersionComponents(WinVer.Major, WinVer.Minor, WinVer.Build, 0);
if (ComparePackedVersion(WinVerPacked, PackVersionComponents(6, 1, 7601, 0)) < 0) or
((ComparePackedVersion(WinVerPacked, PackVersionComponents(6, 2, 0, 0)) >= 0) and
(ComparePackedVersion(WinVerPacked, PackVersionComponents(6, 3, 0, 0)) < 0)) then
begin
MsgBox(SetupMessage(msgWindowsVersionNotSupported), mbError, MB_OK);
Result := False;
end;
위와 유사하게 이것도 작동합니다.
if (WinVerPacked < PackVersionComponents(6, 1, 7601, 0)) or
((WinVerPacked >= PackVersionComponents(6, 2, 0, 0)) and
(WinVerPacked < PackVersionComponents(6, 3, 0, 0))) then
첫 번째 시나리오에서 개선 할 사항이 없습니다.