0

I have this simple function that return the current Windows OS, but it does not work when running over a VMware virtual machine

inline DWORD GetOsVersion()
{
    OSVERSIONINFOEX info;
    ZeroMemory(&info, sizeof(OSVERSIONINFOEX));
    info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    GetVersionEx((LPOSVERSIONINFO)&info);

    return info.dwMajorVersion;
}  

Question :
How to get current operating system version when running over a VMware virtual machine ?

Environment:

  • Visual studio 2010
  • C++11
TonySalimi
  • 8,257
  • 4
  • 33
  • 62
Alpha_33
  • 97
  • 8
  • Which operating systems do you want to support? Linux? Win? Mac? – TonySalimi Jun 01 '20 at 14:57
  • @Gupta Windows 7 and Windows 10 – Alpha_33 Jun 01 '20 at 14:58
  • Why not using `IsWindows10OrGreater()`? See [this link](https://learn.microsoft.com/en-us/windows/win32/api/versionhelpers/nf-versionhelpers-iswindows10orgreater?redirectedfrom=MSDN). – TonySalimi Jun 01 '20 at 15:52
  • @Gupta I dont have the minimum configuration : https://stackoverflow.com/questions/19538873/cannot-open-include-file-versionhelpers-h-no-such-file-or-directory – Alpha_33 Jun 01 '20 at 15:59
  • OK, so which guest operating system you have on VMware? Windows 7? Windows XP? Which version you get with your code on the guest machine? What is wrong with the version that you get? tell us more details about your problem man ! – TonySalimi Jun 02 '20 at 09:39
  • @Gupta Thanks for response. i found solution by using `GetProcAddress` https://stackoverflow.com/questions/32115255/c-how-to-detect-windows-10. The problem was not coming from virtualization but from `GetVersionEx` – Alpha_33 Jun 02 '20 at 20:54

0 Answers0