C++ Check if Windows 10 -


i making app os specific can't seem narrow down windows 10, comes windows 8. have tested on window 10 pro , outcome major: 6 min:2. there way check if it's windows 10 more efficiently?

edit: found working api rtlgetversion() works os's properly!

#include "windows.h" #include <iostream> using namespace std; bool equalsmajorversion(dword majorversion) { osversioninfoex osversioninfo; ::zeromemory(&osversioninfo, sizeof(osversioninfoex)); osversioninfo.dwosversioninfosize = sizeof(osversioninfoex); osversioninfo.dwmajorversion = majorversion; ulonglong maskcondition = ::versetconditionmask(0, ver_majorversion, ver_equal); return ::verifyversioninfo(&osversioninfo, ver_majorversion, maskcondition); } bool equalsminorversion(dword minorversion) { osversioninfoex osversioninfo; ::zeromemory(&osversioninfo, sizeof(osversioninfoex)); osversioninfo.dwosversioninfosize = sizeof(osversioninfoex); osversioninfo.dwminorversion = minorversion; ulonglong maskcondition = ::versetconditionmask(0, ver_minorversion, ver_equal); return ::verifyversioninfo(&osversioninfo, ver_minorversion, maskcondition); } int main() {     if (equalsmajorversion(7) && equalsminorversion(1))         printf("maj:7 min:1");     else if (equalsmajorversion(7) && equalsminorversion(0))         printf("maj:7 min:0");     else if (equalsmajorversion(6) && equalsminorversion(7))         printf("maj:6 min:7");     else if (equalsmajorversion(6) && equalsminorversion(6))         printf("maj:6 min:6");     else if (equalsmajorversion(6) && equalsminorversion(5))         printf("maj:6 min:5");     else if (equalsmajorversion(6) && equalsminorversion(4))         printf("maj:6 min:4");     else if (equalsmajorversion(6) && equalsminorversion(3))         printf("maj:6 min:3");     else if (equalsmajorversion(6) && equalsminorversion(2))         printf("maj:6 min:2");     else if (equalsmajorversion(6) && equalsminorversion(1))         printf("maj:6 min:1");     else if (equalsmajorversion(6) && equalsminorversion(0))         printf("maj:6 min:0");     else if (equalsmajorversion(5) && equalsminorversion(2))         printf("maj:5 min:2");     else if (equalsmajorversion(5) && equalsminorversion(1))         printf("maj:5 min:1");     else         printf("os not on list...");     getchar(); } 

this pretty ironic, but...

bool winapi iswindows10orgreater(void); 

docs here.

edit: geniuses redmond appear have problems thinking prototypes, or in other words, op gets undefined symbol error stated in comments. there's function:

bool winapi iswindowsversionorgreater(     word wmajorversion,     word wminorversion,     word wservicepackmajor ); 

and, windows 10, wmajorversion, wminorversion, , wservicepackmajor appear be, respectively, 10, 0, , 0.

docs function here.

second edit: it's official: iswindowsversionorgreater() , getversionex() broken 8.1 onwards. use iswindowsxxxorgreater() instead, xxx can xp, xpsp1, xpsp2, xpsp3, vista, vistasp1, vistasp2, 7, 7sp1, 8, 8point1, 10, or server.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -