-1
我想編寫一個C++程序,標識當前的Windows版本。 我看到了許多這樣的問題和答案,但他們都沒有爲我工作。與Windows 10家庭C++ Windows版本問題
我正在運行Windows 10家庭版。
我使用Visual Studio中,我已經試過2015年
第一選擇:
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
cout << osvi.dwMajorVersion << endl;
cout << osvi.dwMinorVersion << endl;
這將打印6和2根據MSDN對應於Windows 8的
第二選項我曾嘗試過:
#include <VersionHelpers.h>
if (IsWindowsVistaOrGreater())
printf("VistaOrGreater\n");
if (IsWindows7OrGreater())
printf("Windows7OrGreater\n");
if (IsWindows8OrGreater())
printf("Windows8OrGreater\n");
if (IsWindows8Point1OrGreater())
printf("Windows8Point1OrGreater\n");
if (IsWindows10OrGreater())
printf("Windows10OrGreater\n");
這樣, IsWindows10OrGreater()沒有在我的系統中定義,並給出編譯錯誤。
對此有何幫助?
那麼對於Windows 10來說唯一的辦法就是通過這個體現? – mbaros
@mbaros顯然不是。鏈接的問題有一個非常聰明的解決方案,你可以嘗試。 – jhbh
是的。我已經看到了。謝謝 – mbaros