Get OSVersion in Windows using C++ -
i have osversion
of windows8
system (version should nt 6.2
) use in c++ application. tried using getversion
function call. returned me raw value 602931718
. there way can versions listed here or how can convert raw value readable form?
have looked @ getversionex() function , osversioninfoex structure?
possible usage:
void print_os_info() { osversioninfoex info; zeromemory(&info, sizeof(osversioninfoex)); info.dwosversioninfosize = sizeof(osversioninfoex); getversionex(&info); printf("windows version: %u.%u\n", info.dwmajorversion, info.dwminorversion); }
i don't understand, mean nt
. according msdn:
since windows xp, versions implicitly nt
versions. if want test against server versions, check value of info.wproducttype
:
if(info.dwmajorversion == 6) { if (info.dwminorversion == 0) { if (info.wproducttype == ver_nt_workstation) //windows vista; else //windows server 2008 } else if (info.dwminorversion == 1) { if (info.wproducttype == ver_nt_workstation) //windows 7 else //windows server 2008 r2 } else if (...) //etc... }
and 1 more thing: can check value of info.dwbuildnumber
. 1 of allowed values ver_platform_win32_nt
.
Comments
Post a Comment