如何判断当前操作系统的版本
【打印文章】
徐景周
//------------------------------------------------------------------------------------------------
//判断操作系统涵数及变量,jingzhou xu
typedef enum tagWin32SysType{
Windows32s,
WindowsNT3,
Windows95,
Windows98,
WindowsME,
WindowsNT4,
Windows2000,
WindowsXP
}Win32SysType;
//判断操作系统涵数及变量,jingzhou xu
Win32SysType IsShellSysType()
{
Win32SysType ShellType;
DWORD winVer;
OSVERSIONINFO *osvi;
winVer=GetVersion();
if(winVer<0x80000000){/*NT */
ShellType=WindowsNT3;
osvi= (OSVERSIONINFO *)malloc(sizeof(OSVERSIONINFO));
if (osvi!=NULL){
memset(osvi,0,sizeof(OSVERSIONINFO));
osvi->dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(osvi);
if(osvi->dwMajorVersion==4L)ShellType=WindowsNT4;
else if(osvi->dwMajorVersion==5L&&osvi->dwMinorVersion==0L)ShellType=Windows2000;
else if(osvi->dwMajorVersion==5L&&osvi->dwMinorVersion==1L)ShellType=WindowsXP;
free(osvi);
}
}
else if (LOBYTE(LOWORD(winVer))<4)
ShellType=Windows32s;
else{
ShellType=Windows95;
osvi= (OSVERSIONINFO *)malloc(sizeof(OSVERSIONINFO));
if (osvi!=NULL){
memset(osvi,0,sizeof(OSVERSIONINFO));
osvi->dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(osvi);
if(osvi->dwMajorVersion==4L&&osvi->dwMinorVersion==10L)ShellType=Windows98;
else if(osvi->dwMajorVersion==4L&&osvi->dwMinorVersion==90L)ShellType=WindowsME;
free(osvi);
}
}
return ShellType;
}
//------------------------------------------------------------------------------------------------
用法 :
//Win98、95、32下不用,jingzhou xu
Win32SysType SysType = IsShellSysType();
if(SysType != Windows32s && SysType != Windows95 && SysType !=Windows98)
{
//显示动态GIF图像logo,jingzhou xu
if (m_Picture.Load(MAKEINTRESOURCE(IDR_GIF),_T("GIF")))
{
m_Picture.Draw();
}
}
//------------------------------------------------------------------------------------------------
//判断操作系统涵数及变量,jingzhou xu
typedef enum tagWin32SysType{
Windows32s,
WindowsNT3,
Windows95,
Windows98,
WindowsME,
WindowsNT4,
Windows2000,
WindowsXP
}Win32SysType;
//判断操作系统涵数及变量,jingzhou xu
Win32SysType IsShellSysType()
{
Win32SysType ShellType;
DWORD winVer;
OSVERSIONINFO *osvi;
winVer=GetVersion();
if(winVer<0x80000000){/*NT */
ShellType=WindowsNT3;
osvi= (OSVERSIONINFO *)malloc(sizeof(OSVERSIONINFO));
if (osvi!=NULL){
memset(osvi,0,sizeof(OSVERSIONINFO));
osvi->dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(osvi);
if(osvi->dwMajorVersion==4L)ShellType=WindowsNT4;
else if(osvi->dwMajorVersion==5L&&osvi->dwMinorVersion==0L)ShellType=Windows2000;
else if(osvi->dwMajorVersion==5L&&osvi->dwMinorVersion==1L)ShellType=WindowsXP;
free(osvi);
}
}
else if (LOBYTE(LOWORD(winVer))<4)
ShellType=Windows32s;
else{
ShellType=Windows95;
osvi= (OSVERSIONINFO *)malloc(sizeof(OSVERSIONINFO));
if (osvi!=NULL){
memset(osvi,0,sizeof(OSVERSIONINFO));
osvi->dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(osvi);
if(osvi->dwMajorVersion==4L&&osvi->dwMinorVersion==10L)ShellType=Windows98;
else if(osvi->dwMajorVersion==4L&&osvi->dwMinorVersion==90L)ShellType=WindowsME;
free(osvi);
}
}
return ShellType;
}
//------------------------------------------------------------------------------------------------
用法 :
//Win98、95、32下不用,jingzhou xu
Win32SysType SysType = IsShellSysType();
if(SysType != Windows32s && SysType != Windows95 && SysType !=Windows98)
{
//显示动态GIF图像logo,jingzhou xu
if (m_Picture.Load(MAKEINTRESOURCE(IDR_GIF),_T("GIF")))
{
m_Picture.Draw();
}
}
本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )
【编程爱好者论坛】