inno setup判断是Windows系统版本

1.设置Windows最低版本要求

   [Setup]: MinVersion

   格式: a.bb,c.dd,这里 a.bb 是 Windows 版本,c.dd 是 Windows NT 版本。  

   默认值: 4.0,4.0   

   描述:这个指令让你指定你的软件运行必须的 Windows 或 Windows NT 版本最小版本,要防止你的程序在 Windows 或 Windows NT 下运行,请在最小版本中的一个指定“0”。构建号和/或安全服务包级别可以包含在版本号中。如果用户系统不适合最小版本需求,安装程序将出现一个错误消息并退出。

 

2. 在[Code]段判断系统版本

   语法:procedure GetWindowsVersionEx(var Version: TWindowsVersion);

   描述:返回记录中有关 Windows 版本的扩展信息。

   TWindowsVersion 定义: 

   TWindowsVersion = record

       Major: Cardinal;                    // 主版本号
       Minor: Cardinal;                    // 副版本号
       Build: Cardinal;                     // 构建号
       ServicePackMajor: Cardinal;   // 服务包主版本号
       ServicePackMinor: Cardinal;   // 服务包副版本号
       NTPlatform: Boolean;           // 如果是基于 NT 平台则为 True
       ProductType: Byte;             // 产品类型 (看下面)
       SuiteMask: Word;              // 安装的产品组件 (看下面)
   end; 

   ProductType 对象取值可以是下列值中的一个:

   VER_NT_WORKSTATION               // 表示非服务器版本的 Windows (例如工作站、专业版或家庭版)

   VER_NT_DOMAIN_CONTROLLER
   VER_NT_SERVER

   (如果用户运行于 Windows 95/98/Me,或产品类型不能确定,它也可以是零。)

   SuiteMask 对象取值可以是下列值的组合: 

   VER_SUITE_BACKOFFICE

   VER_SUITE_BLADE                       // 设置在网络版的 Windows Server 2003
   VER_SUITE_DATACENTER
   VER_SUITE_ENTERPRISE
   VER_SUITE_EMBEDDEDNT
   VER_SUITE_PERSONAL                  // 设置在比如家庭版的 Windows XP
   VER_SUITE_SINGLEUSERTS
   VER_SUITE_SMALLBUSINESS
   VER_SUITE_SMALLBUSINESS_RESTRICTED
   VER_SUITE_TERMINAL

   (在 Windows 95/98/Me 和 NT 4.0,SuiteMask 总是为零。)


3.实例

   下面的例子告诉你可以怎样在某些版本的 Windows 中不接受安装,并在多个操作系统版梧检查服务包等级。

    ExpandedBlockStart.gif代码

[Code]
function  InitializeSetup: Boolean;
var
  Version: TWindowsVersion;
  S: String;
begin
  GetWindowsVersionEx(Version);

  
//  不接受在家庭版的 Windows 中安装
  
if  Version.SuiteMask  and  VER_SUITE_PERSONAL  <>   0   then
  
begin
    SuppressibleMsgBox(
' 这个程序不能安装于家庭版的 Windows。 ' ,
      mbCriticalError, MB_OK, MB_OK);
    Result :
=  False;
    Exit;
  
end ;

  
//  不接受在域控制器中安装
  
if  Version.ProductType  =  VER_NT_DOMAIN_CONTROLLER  then
  
begin
    SuppressibleMsgBox(
' 这个程序不能安装于域控制器。 ' ,
      mbCriticalError, MB_OK, MB_OK);
    Result :
=  False;
    Exit;
  
end ;

  
//  在 Windows  2000 ,检查 SP4
  
if  Version.NTPlatform  and
     (Version.Major 
=   5 and
     (Version.Minor 
=   0 and
     (Version.ServicePackMajor 
<   4 then
  
begin
    SuppressibleMsgBox(
' 在 Windows 2000 运行时,必须安装 Service Pack 4。 ' ,
      mbCriticalError, MB_OK, MB_OK);
    Result :
=  False;
    Exit;
  
end ;

  
//  在 Windows XP 中,检查 SP2
  
if  Version.NTPlatform  and
     (Version.Major 
=   5 and
     (Version.Minor 
=   1 and
     (Version.ServicePackMajor 
<   2 then
  
begin
    SuppressibleMsgBox(
' 在 Windows XP 运行时,必须安装 Service Pack 2。 ' ,
      mbCriticalError, MB_OK, MB_OK);
    Result :
=  False;
    Exit;
  
end ;

  Result :
=  True;
end

 

 

转载于:https://www.cnblogs.com/pyw0818/archive/2011/01/22/1941963.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值