This is the function I coded, obviously used to get the system name:
const char* os(){
OSVERSIONINFO os;
ZeroMemory(&os, sizeof(OSVERSIONINFO));
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&os);
std::string ret = "Windows ";
if (os.dwMajorVersion == 10)
ret += "10";
else if (os.dwMajorVersion == 6){
if (os.dwMinorVersion == 3)
ret += "8.1";
else if (os.dwMinorVersion == 2)
ret += "8";
else if (os.dwMinorVersion == 1)
ret += "7";
else
ret += "Vista";
}
else if (os.dwMajorVersion == 5){
if (os.dwMinorVersion == 2)
ret += "XP SP2";
else if (os.dwMinorVersion == 1)
ret += "XP";
}
return ret.c_str();
}
This function returns a the pointer to a memory buffer which is deallocated at the function leaving (object dynamically allocated in the heap, not in the stack)