How I can check in C++ if Windows version installed on computer is Windows Vista and higher (Windows 7)?
+1
A:
This Microsoft support page gives you details for older versions.
You could implement the code and run it on a Vista and Windows-7 machine to check the values returned.
ChrisF
2009-12-26 18:35:18
+4
A:
Use GetVersionEx API function defined in kernel32.dll
:
bool IsWindowsVistaOrHigher() {
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
return osvi.dwMajorVersion >= 6;
}
Mehrdad Afshari
2009-12-26 18:35:40
+2
A:
Similar to other tests for checking the version of Windows NT:
OSVERSIONINFO vi;
memset (&vi, 0, sizeof vi);
vi .dwOSVersionInfoSize = sizeof vi;
GetVersionEx (&vi);
if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT && vi.dwMajorVersion >= 6)
wallyk
2009-12-26 18:36:36
Why must the platform be 32-bit?
Shmoopty
2009-12-26 22:12:04
It needs to be sure it isn't 16 bit windows 95/98/ME or Win32s for MajorVersion not to be confused. I suppose it should allow WIN64 as well, but I can't find the macro name.
wallyk
2009-12-26 23:50:32
A:
You could use the GetVersion() or GetVersionEx() function in the kernel32.dll. This two functions are only available on Windows 2000 or later.
To read more about this look at http://msdn.microsoft.com/en-us/library/ms724451%28VS.85%29.aspx.
jpyllman
2009-12-26 18:43:18