我应该安装什么才能在 C++ 中使用命名空间 Windows::Devices?

What should I install to use namespace Windows::Devices in c++?

现在我要使用蓝牙连接到设备,所以我有一些源代码。 它使用命名空间 Windows::Devices,但我的 visual studio 给我编译错误。

using namespace Windows::Devices;

我想我必须另外安装一些软件包,但我不确定我必须安装什么。 有知道的请帮帮我

由于问题被标记为 I'm going to assume that that's the programming language you are using. The most convenient way to consume Windows Runtime types from C++ is through C++/WinRT. It consists of both a base library as well as a code generator. The code generator is responsible for providing the "projected types" (see Consume APIs with C++/WinRT),生成到名称空间中,例如 Windows::Devices.

项目通常会动态生成包含投影类型的 header,然后可以像任何其他 header 一样将其包含在内。使用 C++/WinRT VSIX extension does that. Those projects have a reference to the Microsoft.Windows.CppWinRT NuGet 包创建的项目,其中包含代码生成器以及在构建期间驱动它的项目属性。

之前,包含预计 C++/WinRT 类型的 header 文件已通过 Windows SDK 交付。它们仍然是 SDK 的一部分,并且可以由客户端代码使用,尽管最好改用 NuGet 包。您会在 Windows.Devices.h header 文件下找到 %WindowsSdkDir%Include\cppwinrt\winrt,因此要使用此命名空间,您需要包含该文件。