開発マシンでWindows 10を実行しています。 10. Tried thisのメジャーバージョンを返すようにOSバージョンを取得しようとしましたが、System::Environment::OSVersion->VersionString
で環境変数も試しました。どちらもMicrosoft Windows NT 6.2.9200
です。 Windows 7マシンで実行可能ファイルをテストしたところ、6.1.*
(正しい)が得られました。MSVC OSVersionが不正なバージョンを返す
私は正しい結果を得るPowerShellでこれを実行している:私は(私は
#include <Windows.h>
#include <iostream>
using namespace std;
int main(int argc, char **argv, char** envp) {
printf("Current compiler version is ... %d\n", _MSC_VER);
printf("Current compiler full version is ... %d\n", _MSC_FULL_VER);
printf("Current OSVersion is ... %s\n\n", System::Environment::OSVersion->VersionString);
char** env;
for (env = envp; *env != 0; env++)
{
char* thisEnv = *env;
printf("%s\n", thisEnv);
}
cin.ignore();
cin.ignore();
return 0;
}
はそれを結果...同じ環境変数のロジックを使用してVisual StudioでテストC++プログラムを書いた
PS Z:\> [System.Environment]::OSVersion.Version
Major Minor Build Revision
----- ----- ----- --------
10 0 14393 0
を...
Current compiler version is ... 1900
Current compiler full version is ... 190024215
Current OSVersion is ... Microsoft Windows NT 6.2.9200.0
...
OS=Windows_NT
上記のテストpターゲットプラットフォームが10.0.14393.0
と設定されています。
なぜ私のOSはWindows 8だと思いますか?
仕様:
- のWindows 10
- バージョン10.0.14393 14393
- のVisual Studio 2015(C++プロジェクト)
- ターゲットプラットフォーム10.0.14393.0
- PowerShellを構築しますバージョン5.1
を参照してください;' (https://stackoverflow.com/q/1452721/2176813)、決してそれを使用しないでください。 – tambre
[app.manifestをプロジェクトに追加し、8.1および10のサポートされているOS GUIDを追加](https://stackoverflow.com/a/40681525/1466046)。今それは動作します。 – magicandre1981
[C#のWindows 10で現在のバージョンのOSを取得]の可能な複製(https://stackoverflow.com/questions/40672109/get-current-version-os-in-windows-10-in-c-sharp) – magicandre1981