My application is running on Vista?
Yesterday I find an answer to the following question: my application is running on Vista or not? The following is a peice of code which gets the Windows version of the underling operating system including the latest release of Vista:
#define OS_UNKNOWN -1
#define OS_NT4 0
#define OS_2000 1
#define OS_XP 2
#define OS_2003 3
#define OS_VISTA 4
int getWinVer()
{
OSVERSIONINFO osVerInfo;
osVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osVerInfo);
if(osVerInfo.dwMajorVersion == 6)
{
return OS_VISTA;
}
else if(osVerInfo.dwMajorVersion == 5)
{
if(osVerInfo.dwMinorVersion == 2)
{
return OS_2003;
}
else if(osVerInfo.dwMinorVersion == 1)
{
return OS_XP;
}
else if(osVerInfo.dwMinorVersion == 0)
{
return OS_2000;
}
}
else if(osVerInfo.dwMajorVersion <= 4)
{
return OS_NT4;
}
else
{
return OS_UNKNOWN;
}
}