飘云阁

 找回密码
 加入我们

QQ登录

只需一步,快速开始

查看: 3306|回复: 0

判断当前操作系统

[复制链接]

该用户从未签到

发表于 2006-1-9 17:56:08 | 显示全部楼层 |阅读模式
原文来自:
http://blog.gameres.com/thread.asp?BlogID=155&threadid=20286
//判断操作系统版本
#include <windows.h>
/*++------------------------------------------------------------------------
Function:
IsWin9x
Modification History:
Jurassic 03/17/2003 Created.
--------------------------------------------------------------------------*/
bool
__stdcall
IsWin9x(
  void
  )
{
OSVERSIONINFO VerInfo;
bool bRet=false;
VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if ( GetVersionEx(&VerInfo))
{
  if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
  {
    bRet=true;
  }
}
return (bRet);
}
/*++------------------------------------------------------------------------
Function:
IsWinNt
Modification History:
Jurassic 03/17/2003 Created.
--------------------------------------------------------------------------*/
bool
__stdcall
IsWinNt(
  void
  )
{
OSVERSIONINFO VerInfo;
bool bRet=false;
VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if( GetVersionEx(&VerInfo))
{
  if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
VerInfo.dwMajorVersion == 4)
  {
    bRet=true;
  }
}
return (bRet);
}
/*++------------------------------------------------------------------------
Function:
IsWin2k
Modification History:
Jurassic 03/17/2003 Created.
--------------------------------------------------------------------------*/
bool
__stdcall
IsWin2k(
  void
  )
{
OSVERSIONINFO VerInfo;
bool bRet=false;
VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if( GetVersionEx(&VerInfo))
{
  if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
VerInfo.dwMajorVersion == 5 &&
VerInfo.dwMinorVersion == 0)
  {
    bRet=true;
  }
}
return (bRet);
}
/*++------------------------------------------------------------------------
Function:
IsWinxp
Modification History:
Jurassic 03/17/2003 Created.
--------------------------------------------------------------------------*/
bool
_stdcall
IsWinXp(
  void
  )
{
OSVERSIONINFO VerInfo;
bool bRet=false;
VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if( GetVersionEx(&VerInfo))
{
  if (VerInfo.dwPlatformId==VER_PLATFORM_WIN32_NT &&
VerInfo.dwMajorVersion == 5 &&
VerInfo.dwMinorVersion == 1)
  {
    bRet=true;
  }
}
return (bRet);
}
补充一下
原型
BOOL GetVersionEx(
LPOSVERSIONINFO lpVersionInformation);

typedef struct _OSVERSIONINFO{
DWORD dwOSVersionInfoSize;
DWORD dwMajorVersion;
DWORD dwMinorVersion;
DWORD dwBuildNumber;
DWORD dwPlatformId;
TCHAR szCSDVersion[128];
} OSVERSIONINFO;

参数具体含义MSDN中有具体解释,偶就不画蛇添足了

对LongHorn系统的判断
这个我在MSDN2003没有发现,不知道2005里有没有
PYG19周年生日快乐!
您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

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