How I can check in C++ if Windows version installed on computer is Windows Vista and higher (Windows 7)?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
This Microsoft support page gives you details for older versions.
You could implement the code and run it on a Vista and Windows-7 machine to check the values returned.
To get the operating system version information make the following call:
Use GetVersionEx API function defined in
kernel32.dll
:I think you're looking for the GetVersionEx function.
All the answers in this thread point you to using
GetVersion
orGetVersionEx
for this test, which is incorrect. It seems to work, but it is risky. The primary source of appcompat problems for Windows OS upgrades comes from poorly written tests based onGetVersion
results with bad assumptions or buggy comparisons.The correct way to do this test is to use
VerifyVersionInfo
, notGetVersion
orGetVersionEx
.If you are using the VS 2013 compiler toolset and the Windows 8.1 SDK, you can use the
VersionHelpers.h
and just callIsWindowsVistaOrGreater
.Otherwise, use:
This code will work on Windows 2000 or later and give you a robust result. If you really needed this test to run on Windows 98 or Windows ME -and- you are using a compiler toolset old enough to actually run on that platform, you'd do the same test but with explicit rather than implicit linking. What's in a version number?
Furthermore, using
GetVersion
orGetVersionEx
will by default get the wrong version on Windows 8.1 and Windows 10. See Manifest Madness.See also this stack overflow thread.
You could use the GetVersion() or GetVersionEx() function in the kernel32.dll. This two functions are only available on Windows 2000 or later.
To read more about this look at http://msdn.microsoft.com/en-us/library/ms724451%28VS.85%29.aspx.
Similar to other tests for checking the version of Windows NT: