I'm writing a C++ code to determine what OS it is running on. I use GetVersionEx()
API to do that, and this code as a tutorial, but it doesn't seems to handle Windows 8. Does anyone know how to fix it to run under Windows 8?
相关问题
- 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
Windows 8 is 6.2.
Windows Server 2012 is also 6.2.
See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724834(v=vs.85).aspx
According to this MSDN page, it is actually recommended to use the Version Helper functions instead of
GetVersionInfoEx
to determine the running Windows version. As described on theGetVersionEx
page, that API may disappear in the future.Another option using the
Win32_OperatingSystem
WMI classThis code returns
On Windows 8 developer preview version.
OK, I was hoping someone has done this already ... but, I guess not, so here you go:
Windows 8 Consumer Preview
PS. I don't have VS IDE installed there. Had to make a small app to get those...
Another possible method for basic (major, minor) validation of the system but not in depth product details is to check the version of a core system file, example kernel32.dll.
Credits to another thread for usage on GetFileVersionEx...
Sorry for the late bump.. ;)
According to several comments in the MSDN forums and this article the version number for Windows 8 is 6.2
This is the sample code updated and tested in Windows 8 Developer Preview
This returns
Microsoft Windows 8 (build 8102), 64-bit
on my Windows 8 Test Machine