I am using Inno for creating a setup file. I'm stuck at detecting my OS type. Does anyone know how to check whether my OS is Windows XP or higher?
Asked
Active
Viewed 5,422 times
1
-
2possible duplicate of [Determine Windows version in Inno Setup](http://stackoverflow.com/questions/5849917/determine-windows-version-in-inno-setup) – Jon Aug 28 '13 at 12:19
2 Answers
2
If you're wanting to do this because XP is your minimum version of Windows required, then you can just use:
[Setup]
MinVersion=0,6.01
Which will prevent the installer from running on anything older than XP.
Alternatively you can do the same thing for individual files by using something like this:
Source: ...; MinVersion: 0,6.01
^ will install the file only on XP or above
Source: ...; OnlyBelowVersion: 0,6.01
^ will install the file only on pre-XP versions

Miral
- 12,637
- 4
- 53
- 93
-
Or if you need to test this from code, you may use e.g. the example shown in the [`GetWindowsVersion`](http://www.jrsoftware.org/ishelp/index.php?topic=isxfunc_getwindowsversion) function reference. – TLama Aug 28 '13 at 21:57
1
GetWindowsVersionEx see this function in inno setup help file
Check this Code would work for you
procedure Initializewizard;
begin
{
GetWindowsVersionEx(Version);
//windows version information
//5.0.2195 Windows 2000
//5.1.2600 Windows XP or Windows XP 64-Bit Edition Version 2002 (Itanium)
//5.2.3790 Windows Server 2003 or Windows XP x64 Edition (AMD64/EM64T) or Windows XP 64-Bit Edition Version 2003 (Itanium)
//6.0.6000 Windows Vista
//6.1.7600 Windows 7 or Windows Server 2008 R2
//6.2.9200 Windows 8 or Windows Server 2012
//Note that there is normally no need to specify the build numbers (i.e., you may simply use "5.1" for Windows XP).
if (Version.Major = 5) and
(Version.Minor = 0) then
Msgbox('THIS IS Windows 2000 EDITION', mbInformation,MB_OK)
if (Version.Major = 5) and
(Version.Minor = 1) then
Msgbox('THIS IS Windows XP or Windows XP 64-Bit Edition Version 2002 (Itanium) ', mbInformation,MB_OK)
if (Version.Major = 5) and
(Version.Minor = 2) then
Msgbox('THIS IS Windows Server 2003 or Windows XP x64 Edition (AMD64/EM64T) or Windows XP 64-Bit Edition Version 2003 (Itanium) ', mbInformation,MB_OK)
if (Version.Major = 6) and
(Version.Minor = 0) then
Msgbox('THIS IS Windows VistaEDITION', mbInformation,MB_OK)
if (Version.Major = 6) and
(Version.Minor = 1) then
Msgbox('THIS IS Windows 7 or Windows Server 2008 R2 EDITION', mbInformation,MB_OK)
if (Version.Major = 6) and
(Version.Minor = 2) then
Msgbox('THIS IS Windows 8 or Windows Server 2012 EDITION', mbInformation,MB_OK )
}
end;
UPDATE:
Give a try to this statement. This Will store the required system info in a file.you can use Loadstringsfromfile to tarraystrings and then use how ever you want to.
Exec('cmd.exe', '/C systeminfo| findstr "OS Name: OS Version: OS Build Type: System Manufacturer: System Model: System Type: Processor(s): Total Physical Memory: Available Physical Memory: Virtual Memory: Max Size: Virtual Memory: Available: Virtual Memory: In Use:" |find /v /i "vmware" |find /v "Hotfix" | find /v "BIOS" |find /v "Locale" |find /v "Directory" |find /v /i "configuration"|find /v "Host Name"|find /v "Connection" |find /v "Date" |find /v "Boot" |find /v "Corporation" > "' + TmpFileName + '"', '', SW_HIDE,ewWaitUntilTerminated, ResultCode);

Gangadhar
- 10,248
- 3
- 31
- 50