杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2293|回复: 0

判断操作系统类型的多种方法

[复制链接]
发表于 2017-1-7 20:02:32 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  用InstallShield制作安装包时,有时候需要判断操作系统的类型(如Windows XP或者是Windows Vista等)

方法一:采用注册表的方式进行判断,例程如下:

  1. NUMBER nOS,nvResult;
  2. STRING svOS;

  3. nOS = REGDB_NUMBER;
  4. RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
  5. RegDBGetKeyValueEx( "SOFTWARE//Microsoft//Windows NT//CurrentVersion","CurrentVersion", nOS, svOS, nvResult);
  6. if (svOS == "6.0") then
  7.     MessageBox("We are on Vista!", INFORMATION);
  8. else
  9.     if (svOS == "5.1") then
  10.         MessageBox("We are on XP!",INFORMATION);
  11.     endif;
  12. endif;
复制代码

方法二:采用GetSystemInfo函数进行处理,请看下面的说明信息:

  1. SYSINFO.nWinMajor:
  2. 4  The operating system is Windows NT 4.0.   
  3. 5  The operating system is Windows Server 2003 R2, Windows Server 2003, Windows   XP,or Windows 2000.  
  4. 6  The operating system is Windows Vista or Windows Server 2008.  
  5. SYSINFO.nWinMinor:
  6. 0  The operating system is Windows Vista, Windows Server 2008, Windows 2000, or Windows NT 4.0.   
  7. 1  The operating system is Windows XP.   
  8. 2  The operating system is Windows Server 2003 R2, Windows Server 2003, or Windows XP Professional x64 Edition.
  9. GetSystemInfo(WINMINOR, nvResult, svResult);
  10. GetSystemInfo(WINMAJOR, nvResult, svResult);
复制代码

方法二可以通过InstallShield的帮助文档找到更详细的信息。

方法三:通过SYSINFO.WINNT的方法进行判断,例程如下:

  1. if (SYSINFO.WINNT.bWinVista) then   
  2.      if (SYSINFO.nOSProductType = VER_NT_WORKSTATION) then  
  3.           // 当前操作系统为Windows Vista
  4.      endif;
  5. endif;
  6. if (SYSINFO.WINNT.bWinXP) then   
  7.     当前操作系统为Windows XP
  8. endif;
复制代码

上述三种方法是最为常见的解决办法,当然亦可能还有其他的方法可以进行处理。






回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-19 19:01 , Processed in 0.121851 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表