• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
BeyondTechnology
博客园    首页    新随笔    联系   管理    订阅  订阅

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

方法一:采用注册表的方式进行判断,例程如下:
NUMBER nOS,nvResult;
STRING svOS;


nOS = REGDB_NUMBER;
RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
RegDBGetKeyValueEx( "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion","CurrentVersion", nOS, svOS, nvResult);
if (svOS == "6.0") then
    MessageBox("We are on Vista!", INFORMATION);
else
    if (svOS == "5.1") then
        MessageBox("We are on XP!",INFORMATION);
    endif;
endif;

方法二:采用GetSystemInfo函数进行处理,请看下面的说明信息:
SYSINFO.nWinMajor:
4  The operating system is Windows NT 4.0.  
5  The operating system is Windows Server 2003 R2, Windows Server 2003, Windows   XP,or Windows 2000.  
6  The operating system is Windows Vista , Windows Server 2008 or Windows 7  

SYSINFO.nWinMinor:
0  The operating system is Windows Vista, Windows Server 2008, Windows 2000, or Windows NT 4.0.  
1  The operating system is Windows XP.  
2  The operating system is Windows Server 2003 R2, Windows Server 2003, or Windows XP Professional x64 Edition. 

GetSystemInfo(WINMINOR, nvResult, svResult);
GetSystemInfo(WINMAJOR, nvResult, svResult);

 

win 95              4.0

win 98              4.1

win 2000win NT)      5.0

win xp(NT5.1)         5.1

win 2003          5.2

win Vista          6.0

win 7               6.1

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

方法三:通过SYSINFO.WINNT的方法进行判断,例程如下:
if (SYSINFO.WINNT.bWinVista) then   
     if (SYSINFO.nOSProductType = VER_NT_WORKSTATION) then 
          // 当前操作系统为Windows Vista
     endif;
endif;
if (SYSINFO.WINNT.bWinXP) then    
    当前操作系统为Windows XP
endif;

posted @ 2010-10-21 23:10  BeyondTechnology  阅读(1364)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3