如何确定安装在我的计算机上的Windows SDK的版本?

时间:2022-03-25 20:26:32

I've very recently decided to teach myself c++ and win32 programming after learning vb.net, and I've got a very simple question:

我最近决定在学习vb.net之后自学c++和win32编程,我有一个非常简单的问题:

How can I determine what version of the Windows SDK is installed on my computer?

如何确定在我的计算机上安装了什么版本的Windows SDK ?

I'm asking so I can install the latest version if it isn't installed already, before I start playing around with c++. I'm using Microsoft Visual Studio 2008 SP1 as my IDE.

我在问,我可以安装最新的版本,如果它还没有安装的话,在我开始玩c++之前。我使用Microsoft Visual Studio 2008 SP1作为我的IDE。

3 个解决方案

#1


32  

On English locale at least:

至少在英语地区:

dir "%ProgramFiles%\Microsoft SDKs\Windows"

should work. It is quite likely that there will be multiple versions installed, which is the right one for an one build can only be specified by that project.

应该工作。很有可能会安装多个版本,这是一个构建的正确版本,只能由该项目指定。

#2


19  

If you need to determine, while compiling, what version of the Windows SDK is being used then you can use the VER_PRODUCTBUILD macro, which is defined in ntverp.h. For instance:

如果需要确定在编译时使用的是什么版本的Windows SDK,那么可以使用在ntverp.h中定义的VER_PRODUCTBUILD宏。例如:

#include <ntverp.h>
#if VER_PRODUCTBUILD > 9600
// Windows 10+ SDK code goes here
#else
// Windows 8.1- SDK code goes here
#endif

In most cases this should not be necessary because a product should be designed to build with a particular platform SDK. But for some large products there may be a desired to support multiple platform SDKs. This can be particularly useful when migrating from one to another. If there is a bug in a header file (such as the bogus "#pragma pop" in the Windows 8.1 SDK version of bthledef.h) then you may need to workaround this bug, but not include the workaround when using the Windows 10 SDK or higher.

在大多数情况下,这是不需要的,因为产品应该被设计成使用特定的平台SDK来构建。但对于某些大型产品,可能需要支持多个平台sdk。这在从一个迁移到另一个时特别有用。如果头文件中有一个bug(比如Windows 8.1 SDK版本的bthledef.h中的伪“#pragma pop”),那么您可能需要解决这个bug,但在使用Windows 10 SDK或更高版本时,不包括解决方法。

#3


19  

The current version of the Windows SDK is stored in the CurrentVersion value of the following registry key:

Windows SDK的当前版本存储在以下注册表项的当前版本值中:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows

如何确定安装在我的计算机上的Windows SDK的版本?

and it can be retrieved using this PowerShell one-liner:

可以使用PowerShell一行程序来检索:

$(Get-Item "hklm:\SOFTWARE\Microsoft\Microsoft SDKs\Windows").GetValue("CurrentVersion")

如何确定安装在我的计算机上的Windows SDK的版本?

#1


32  

On English locale at least:

至少在英语地区:

dir "%ProgramFiles%\Microsoft SDKs\Windows"

should work. It is quite likely that there will be multiple versions installed, which is the right one for an one build can only be specified by that project.

应该工作。很有可能会安装多个版本,这是一个构建的正确版本,只能由该项目指定。

#2


19  

If you need to determine, while compiling, what version of the Windows SDK is being used then you can use the VER_PRODUCTBUILD macro, which is defined in ntverp.h. For instance:

如果需要确定在编译时使用的是什么版本的Windows SDK,那么可以使用在ntverp.h中定义的VER_PRODUCTBUILD宏。例如:

#include <ntverp.h>
#if VER_PRODUCTBUILD > 9600
// Windows 10+ SDK code goes here
#else
// Windows 8.1- SDK code goes here
#endif

In most cases this should not be necessary because a product should be designed to build with a particular platform SDK. But for some large products there may be a desired to support multiple platform SDKs. This can be particularly useful when migrating from one to another. If there is a bug in a header file (such as the bogus "#pragma pop" in the Windows 8.1 SDK version of bthledef.h) then you may need to workaround this bug, but not include the workaround when using the Windows 10 SDK or higher.

在大多数情况下,这是不需要的,因为产品应该被设计成使用特定的平台SDK来构建。但对于某些大型产品,可能需要支持多个平台sdk。这在从一个迁移到另一个时特别有用。如果头文件中有一个bug(比如Windows 8.1 SDK版本的bthledef.h中的伪“#pragma pop”),那么您可能需要解决这个bug,但在使用Windows 10 SDK或更高版本时,不包括解决方法。

#3


19  

The current version of the Windows SDK is stored in the CurrentVersion value of the following registry key:

Windows SDK的当前版本存储在以下注册表项的当前版本值中:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows

如何确定安装在我的计算机上的Windows SDK的版本?

and it can be retrieved using this PowerShell one-liner:

可以使用PowerShell一行程序来检索:

$(Get-Item "hklm:\SOFTWARE\Microsoft\Microsoft SDKs\Windows").GetValue("CurrentVersion")

如何确定安装在我的计算机上的Windows SDK的版本?