0

I'm trying to identify Windows version using IsWindows10OrGreater() and other related functions.

C++, Windows 7 Home Basic, Visual Studio Code v1.36.1, VSCode Extensions - C/C++ for Visual Studio Code, MinGW g++ v8.2.0

Compilation command:

g++ -std=c++11 main.cpp -o file.exe -s -lws2_32 -Wno-write-strings -fno-exceptions -fmerge-all-constants -fpermissive -static-libstdc++ -static-libgcc

I included the version helper header using #include <Versionhelpers.h>, but IntelliSense doesn't recognize it and the build also fails with the error:

fatal error: Versionhelpers.h: No such file or directory
#include <Versionhelpers.h>

I tried including the header in a fresh file and building it, but that didn't work either.

#include <Versionhelpers.h>

int main() {
    IsWindowsServer();
    return 1;
}

Is there any extension that I need to install in VSCode to get this to work? Or perhaps download the header file (and put it where?)

Nikhil Hegde
  • 341
  • 1
  • 3
  • 15
  • 1
    `VersionHelpers.h` was inside sdk files, are you install sdk ? anyway such functions (*IsWindows10OrGreater*) in practic useless – RbMm Jul 29 '19 at 21:04
  • I didn't have it. I installed Win 10 SDK and restarted VSCode (no other changes made). Didn't work. There is no other reliable way to determine OS version. `GetVersionEx` is not reliable. – Nikhil Hegde Jul 29 '19 at 21:37
  • 2
    you mistake - the `IsWindows10OrGreater` **not reliable** way. it **exactly** reliable as `GetVersionEx` - both is manifest based. and file in sdk. so you not add paths to sdk. anyway - this is useless api - nothing give more compare `GetVersionEx`. and *no other reliable way to determine OS version* - of course no. other reliable exist and this - not reliable way – RbMm Jul 29 '19 at 21:39
  • 2
    `RtlGetVersion()`, `NetServerGetInfo()`, and `NetWkstaGetInfo()` are reliable ways to get the true OS version number without needing an app manifest. See [How to detect Windows 10](https://stackoverflow.com/questions/32115255) – Remy Lebeau Jul 29 '19 at 23:39
  • Gotcha. I don't know what the downvote is for, but okay. – Nikhil Hegde Jul 29 '19 at 23:55
  • @NikhilHegde If you don't target Windows 10 it will not find header files in Windows 10 SDK path by default. If you target lower version than Windows 10 refer to [this](https://stackoverflow.com/questions/19538873/cannot-open-include-file-versionhelpers-h-no-such-file-or-directory) thread for some resolutions. – Rita Han Jul 31 '19 at 02:20

0 Answers0