且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为 ARM 平台构建时要为 NTSTATUS 包含什么标头?

更新时间:2023-10-15 13:32:58

主要问题是通用 Windows 平台应用(即 Windows 10 应用商店应用)支持 BCRYPT,但支持适用于 Windows 8.x 应用商店应用程序.VS 2013 工具集始终使用 Windows 8.1 SDK,因此您正在构建 Windows 8.1 应用商店应用程序.当您尝试 VS 2012 时,您使用的是 Windows 8.0 SDK,因此您正在构建 Windows 8.0 应用商店应用程序.同样,这两个都不支持 BCRYPT.如果您使用 VS 2015 构建并安装了 Windows 10 SDK,那么您的代码构建良好.

The main issue is that BCRYPT is supported for the Universal Windows Platform apps (aka Windows 10 Store apps), but was not supported for Windows 8.x Store apps. VS 2013 toolset always uses the Windows 8.1 SDK so you were building a Windows 8.1 Store app. When you tried VS 2012, you were using the Windows 8.0 SDK so you were building a Windows 8.0 Store apps. Again, neither of this support BCRYPT. If you build with VS 2015 and have the Windows 10 SDK installed, then your code builds fine.

请注意,/D_MBCS 不是 Windows 应用商店应用程序的选项.所有 Windows 应用商店应用程序都应该为 Unicode /DUNICODE/D_UNICODE 而不是您尝试做的 ANSI/Multibyte 构建.

Note that /D_MBCS is not an option for Windows Store apps. All Windows Store apps should be built for Unicode /DUNICODE /D_UNICODE and not ANSI/Multibyte as you were trying to do.

另外,请务必与 windowsapp.lib 链接,以确保在链接时选择正确的 DLL.

Also, be sure to link with windowsapp.lib to make sure you pick up the correct DLLs when you link.

如果文件中根本没有 #include <bcrypt.h>,您可以轻松确认您看到的所有错误都发生在 VS 2012/2013 中.DWINAPI_FAMILY=WINAPI_FAMILY_APP 确保所有不受支持的 API 都是未定义的,因此对于 Windows 8.x Store,该标头基本上是一个空文件.

You can easily confirm that all the errors you are seeing happen in VS 2012/2013 if you do not have #include <bcrypt.h> in the file at all. The DWINAPI_FAMILY=WINAPI_FAMILY_APP ensures that all unsupported APIs are undefined, so with Windows 8.x Store that header was basically an empty file.