1. Set minimum Windows version requirements
[Setup]:Minversion
Format: A. BB, C. dd. Here, A. BB is a Windows version, and C. DD is a Windows NT version.
Default: 4.0, 4.0
Description: This command allows you to specify the minimum Windows or Windows NT version required for running your software. To prevent your program from running on Windows or Windows NT, specify "0" in one of the minimum versions ". The build number and/or security service package level can be included in the version number. If the user system is not suitable for the minimum version requirement, an error message will appear in the installer and exit.
2. Determine the system version in the [Code] segment
Syntax: Procedure getwindowsversionex (VAR version: twindowsversion );
Description: Windows extension information in the record.
TwindowsversionDefinition:
Twindowsversion = record
Major: Cardinal; // major version number minor: Cardinal; // minor version number build: Cardinal; // build number servicepackmajor: Cardinal; // service package main version number servicepackminor: Cardinal; // service package minor version ntplatform: Boolean; // true producttype: byte if it is based on the NT platform; // product type (see the following) suitemask: word; // install the product components (see the following)
End;
ProducttypeThe object value can be one of the following values:
Ver_nt_workstation // indicates a non-server version of Windows (such as workstation, Professional Edition, or Home Edition)
Ver_nt_domain_controller ver_nt_server
(If the user runs on Windows 95/98/me, or the product type cannot be determined, it can also be zero .)
SuitemaskThe object value can be a combination of the following values:
Ver_suite_backoffice
Ver_suite_blade // set Windows Server 2003 ver_suite_datacenter ver_suite_enterprise license ver_suite_personal on the Windows XP license ver_suite_smallbusiness license ver_suite_terminal
(In Windows 95/98/me and NT 4.0, suitemask is always zero .)
3. Instance
The following example shows how to disable installation in some versions of Windows and check the service package level in multiple OS versions.
Code
[Code]
Function initializesetup: Boolean;
VaR
Version: twindowsversion;
S: string;
Begin
Getwindowsversionex (version );
// It is not allowed to be installed in windows of the Home Edition.
If version. suitemask and ver_suite_personal <> 0 then
Begin
Suppressiblemsgbox ('This program cannot be installed on windows in the Home Edition. ',
Mbcriticalerror, mb_ OK, mb_ OK );
Result: = false;
Exit;
End;
// The installation in the domain controller is not accepted
If version. producttype = ver_nt_domain_controller then
Begin
Suppressiblemsgbox ('This program cannot be installed on the domain controller. ',
Mbcriticalerror, mb_ OK, mb_ OK );
Result: = false;
Exit;
End;
// In Windows 2000, check SP4
If version. ntplatform and
(Version. Major = 5) and
(Version. Minor = 0) and
(Version. servicepackmajor <4) then
Begin
Suppressiblemsgbox ('service Pack 4 must be installed when running Windows 2000. ',
Mbcriticalerror, mb_ OK, mb_ OK );
Result: = false;
Exit;
End;
// In Windows XP, check SP2
If version. ntplatform and
(Version. Major = 5) and
(Version. Minor = 1) and
(Version. servicepackmajor <2) then
Begin
Suppressiblemsgbox ('service pack 2 must be installed when running Windows XP. ',
Mbcriticalerror, mb_ OK, mb_ OK );
Result: = false;
Exit;
End;
Result: = true;
End;