내 개발 컴퓨터에서 Windows 10을 실행 중입니다. 10. Tried this의 주요 버전을 반환하도록 OS 버전을 얻으려고 시도했으며 System::Environment::OSVersion->VersionString
을 통해 환경 변수를 시도했습니다. 둘 다 Microsoft Windows NT 6.2.9200
을 반환합니다. Windows 7 컴퓨터에서 실행 파일을 테스트하면 6.1.*
(올바른)이 표시됩니다. 파워 쉘이 실행잘못된 버전을 반환하는 MSVC OSVersion
내가 올바른 결과를 얻을 : 나도 같은 환경 변수의 논리를 사용하여 Visual Studio에서 테스트 C++ 프로그램을 작성
PS Z:\> [System.Environment]::OSVersion.Version
Major Minor Build Revision
----- ----- ----- --------
10 0 14393 0
...
#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;
}
이 결과를 (I 하나를 제외한 모든 환경 변수를 출력하지 않습니다.) ...
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이라고 생각하는 이유는 무엇입니까?
사양 :
- 윈도우 10
- 버전 10.0.14393 14,393
- 비주얼 스튜디오 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