简体   繁体   English

从Inno Setup检查Windows版本时出现问题

[英]Problem with checking the Windows version from Inno Setup

My program installs a driver, which has different versions compiled for XP, Win2003, Vista/Win2008, and Win7. 我的程序安装了一个驱动程序,它有针对XP,Win2003,Vista / Win2008和Win7编译的不同版本。 I use pascal functions to check which is the OS, and install the corresponding DLL. 我使用pascal函数来检查哪个是OS,并安装相应的DLL。

On some users' systems no DLL is installed, which means all the functions have returned false. 在某些用户的系统上没有安装DLL,这意味着所有函数都返回false。 This should not happen so long as the OS's major version is 5 or 6. 只要操作系统的主要版本是5或6,就不会发生这种情况。

Can anyone tell me if there is something wrong with the code I use? 任何人都可以告诉我,我使用的代码是否有问题?

[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

You should use the common parameters MinVersion and OnlyBelowVersion in conjunction with the function IsWin64 . 您应该将常用参数 MinVersionOnlyBelowVersion与函数IsWin64结合使用。

Update 更新

To distinguish between workstation and server versions you can use the GetWindowsVersionEx function which is integrated in Inno Setup. 要区分工作站和服务器版本,可以使用集成在Inno Setup中的GetWindowsVersionEx功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM