вторник, 2 июля 2013 г.

w8.1 preview GetVersionEx - wtf ?

Some simple code:

 ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

 if (!::GetVersionExW((LPOSVERSIONINFOW)&osvi))
   return 0;
 printf("Major %d Minor %d\n", osvi.dwMajorVersion, osvi.dwMinorVersion);

produces output
Major 6 Minor 2

O`k, next code sample:
  memset(&osverEx, 0, sizeof(osverEx));
  osverEx.dwOSVersionInfoSize = sizeof(osverEx);
  NTSTATUS res = RtlGetVersion((PRTL_OSVERSIONINFOW)&osverEx);
  if ( NT_SUCCESS(res) )

    printf("Major %d Minor %d\n", osverEx.dwMajorVersion, osverEx.dwMinorVersion);

produces output:
Major 6 Minor 3
wtf ?

2 комментария:

  1. This is by design. If you are a Blue app, you can either target the sources file to _NT_TARGET_VERSION_WINNT_WINBLUE, or add the compat manifest.

    If you do not do one of these things to specifically indicate that you are a Blue compatible app, GetVersion and GetVersionEx APIs will return a Windows 8 version number (9200).

  2. I just will use RtlGetVersion in next time