如何构建Windows 8.1 SDK

PAK*_*K-9 6 c++ windows winapi visual-studio visual-studio-2012

我的设置如下:

Windows 8.1,Microsoft Visual Studio 2012

我希望构建Windows 8.1 SDK.我的应用程序是c ++,没有Windows运行时组件或类似的东西.

我安装了Windows 8.1 SDK,但Visual Studio正在构建Windows 7 SDK,因此为了切换目标,我修改了指向当前SDK版本的注册表项:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows 注册处

但是,当我在Visual Studio中检查宏时,它现在正在构建针对Windows SDK 8.0而不是8.1.

Visual Studio宏

任何人都可以解释为什么会这样吗?我无法使用我的设置构建Windows 8.1 SDK,是否只能使用Visual Studio 2012?我找不到任何结论性的信息来告诉我它是否得到支持.

Sle*_*Eye 7

这是怎么回事

WindowsSdkDir是一个Visual Studio内部变量,它是根据"Platform Toolset"项目属性(在"Configuration Properties/General"下)从注册表项派生而来的.对于"Visual Studio 2012(v110)"平台工具集,注册表项如:

HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0
HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0
HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.0
HKCU\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.0
Run Code Online (Sandbox Code Playgroud)

使用,不论CurrentVersionCurrentInstallFolder键.

如何使用Visual Studio 2012构建Windows 8.1 SDK

至于在这个博客中描述:

VS 2010/2012用户:您可以使用最初用于VS 2010 + Windows 8.0 SDK的此Visual C++团队博客文章中描述的Windows 8.1 SDK的属性表技术.对于VS 2010,只需将"8.0"/"win8"的路径部分更改为"8.1"/"winv6.3",否则使用所有这些说明.对于VS 2012,您可以简化所有路径,只需在每个变量的现有值之前添加8.1路径.更新的.props附在此博客文章中.这应该只用于Win32桌面应用程序开发.

进行这些更改后,您应该获得一个属性表(也作为同一博客的附件提供),对于x86来说:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <ExecutablePath>$(ProgramFiles)\Windows Kits\8.1\bin\x86;$(ExecutablePath)</ExecutablePath>
    <IncludePath>$(ProgramFiles)\Windows Kits\8.1\Include\um;$(ProgramFiles)\Windows Kits\8.1\Include\shared;$(ProgramFiles)\Windows Kits\8.1\Include\winrt;$(IncludePath)</IncludePath>
    <LibraryPath>$(ProgramFiles)\Windows Kits\8.1\lib\winv6.3\um\x86;$(LibraryPath)</LibraryPath>
    <ExcludePath>$(ProgramFiles)\Windows Kits\8.1\Include\um;$(ProgramFiles)\Windows Kits\8.1\Include\shared;$(ProgramFiles)\Windows Kits\8.1\Include\winrt;$(ExcludePath)</ExcludePath>
  </PropertyGroup>
<ItemDefinitionGroup />
</Project>
Run Code Online (Sandbox Code Playgroud)

同样适用于x64:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <ExecutablePath>$(ProgramFiles)\Windows Kits\8.1\bin\x64;$(ExecutablePath)</ExecutablePath>
    <IncludePath>$(ProgramFiles)\Windows Kits\8.1\Include\um;$(ProgramFiles)\Windows Kits\8.1\Include\shared;$(ProgramFiles)\Windows Kits\8.1\Include\winrt;$(IncludePath)</IncludePath>
    <LibraryPath>$(ProgramFiles)\Windows Kits\8.1\lib\winv6.3\um\x64;$(LibraryPath)</LibraryPath>
    <ExcludePath>$(ProgramFiles)\Windows Kits\8.1\Include\um;$(ProgramFiles)\Windows Kits\8.1\Include\shared;$(ProgramFiles)\Windows Kits\8.1\Include\winrt;$(ExcludePath)</ExcludePath>
  </PropertyGroup>
<ItemDefinitionGroup />
</Project>
Run Code Online (Sandbox Code Playgroud)

但请注意.虽然这将定义构建Windows 8.1 SDK所需的所有路径,但它不会更改WindowSdkDir仍然指向Windows 8.0 SDK的相关宏.如果使用这些宏来定义项目属性,这可能会导致构建不一致.

最后,请注意Visual Studio 2013附带Windows 8.1 SDK,相应地它是与默认"Visual Studio 2013(v120)"平台工具集属性一起使用的SDK.因此,如果升级到VS2013是一个选项,这可能会为您节省一些麻烦.