Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ How to detect Windows 10

Tags:

I have written a PC auditing tool many years ago and have been keeping it up to date. One of basic functions is reporting the version of Windows running on the PC being audited for which I have always used the GetVersionEx call.

This works up to and including Windows 8 but is not supported under Windows 10 and indeed Windows 10 returns 8.2 just as windows 8 does. Microsoft do not seem to have introduced anything as a direct replacement suggesting instead that you check for specific features required rather than looking at the OS but for the purpose of the audit I actually want the OS name.

The 'scanner' is a C++ program which must run under non-privileged accounts so I don't think another suggestion I have read - picking up the version of a system DLL such as kernel32.dll will work as these folders are typically not accessible to users.

Any other suggestions/thoughts are most welcome!

like image 469
user1169502 Avatar asked Aug 20 '15 10:08

user1169502


People also ask

Is Windows 10 made in C?

Microsoft's Windows kernel is developed mostly in C, with some parts in assembly language. For decades, the world's most used operating system, with about 90 percent of the market share, has been powered by a kernel written in C.

How do you check if my window is 10 or 11?

To find out which version of Windows your device is running, press the Windows logo key + R, type winver in the Open box, and then select OK.


1 Answers

GetVersion and GetVersionEx were superseded by various version helper functions. The one you want is IsWindows10OrGreater. They can be found in VersionHelpers.h.

IsWindows10OrGreater is only available in the latest SDK/Visual Studio 2015. You can use IsWindowsVersionOrGreater in the general case however. For example on my 7 box I get TRUE for IsWindowsVersionOrGreater(6, 0, 0).

Remember that the parameters this function takes relate to Windows build number and NOT marketing name. So Windows 8 is build 6.2. Windows 7 is 6.0 etc.

like image 66
Robinson Avatar answered Oct 13 '22 18:10

Robinson