Problem checking version of Windows from Inno Setup

My program installs a driver that has different versions compiled for XP, Win2003, Vista / Win2008 and Win7. I use pascal functions to check which OS and install the appropriate DLL.

Some user systems do not have a DLL installed, which means that all functions returned false. This should not happen if the main OS version is 5 or 6.

Can someone tell me something is wrong with the code I'm using?

[Code]
function UseDriverForWindows7(): Boolean;
var
  Version: TWindowsVersion;
begin
  GetWindowsVersionEx(Version);

  // Windows 7 version is 6.1 (workstation)
  if (Version.Major = 6)  and
     (Version.Minor = 1) and
     (Version.ProductType = VER_NT_WORKSTATION)
  then
    Result := True
  else
    Result := False;
end;

function UseDriverForWindowsVistaAndWindows2008(): Boolean;
var
  Version: TWindowsVersion;
begin
  GetWindowsVersionEx(Version);

  // Anything with major version 6 where we won't use Windows 7 driver
  if (Version.Major = 6) and
     (not UseDriverForWindows7)
  then
    Result := True
  else
    Result := False;
end;

function UseDriverForWindows2003(): Boolean;
var
  Version: TWindowsVersion;
begin
  GetWindowsVersionEx(Version);

  // Windows 2003 version is 5.2 (server)
  if (Version.Major = 5)  and
     (Version.Minor = 2)  and
     (Version.ProductType <> VER_NT_WORKSTATION)
  then
    Result := True
  else
    Result := False;
end;

function UseDriverForWindowsXP(): Boolean;
var
  Version: TWindowsVersion;
begin
  GetWindowsVersionEx(Version);

  // Anything with major version 5 where we won't use Windows 2003 driver
  if (Version.Major = 5) and
     (not UseDriverForWindows2003)
  then
    Result := True
  else
    Result := False;
end;

[Files]
Source: "mydrv-xp-x86.dll"; DestDir: {app}; DestName: mydrv.dll; Check: not IsWin64 and UseDriverForWindowsXP; Flags: ignoreversion
Source: "mydrv-2003-x86.dll"; DestDir: {app}; DestName: mydrv.dll; Check: not IsWin64 and UseDriverForWindows2003; Flags: ignoreversion
Source: "mydrv-vista-x86.dll"; DestDir: {app}; DestName: mydrv.dll; Check: not IsWin64 and UseDriverForWindowsVistaAndWindows2008; Flags: ignoreversion
Source: "mydrv-win7-x86.dll"; DestDir: {app}; DestName: mydrv.dll; Check: not IsWin64 and UseDriverForWindows7; Flags: ignoreversion
Source: "mydrv-xp-x64.dll"; DestDir: {app}; DestName: mydrv.dll; Check: IsWin64 and UseDriverForWindows2003; Flags: ignoreversion
Source: "mydrv-vista-x64.dll"; DestDir: {app}; DestName: mydrv.dll; Check: IsWin64 and UseDriverForWindowsVistaAndWindows2008; Flags: ignoreversion
Source: "mydrv-win7-x64.dll"; DestDir: {app}; DestName: mydrv.dll; Check: IsWin64 and UseDriverForWindows7; Flags: ignoreversion
+3
source share
1 answer

You must use common parameters MinVersion and OnlyBelowVersionin combination with the function IsWin64.

Update

, GetWindowsVersionEx, Inno Setup.

+5

Source: https://habr.com/ru/post/1794653/


All Articles