Home > Net >  What should I install to use namespace Windows::Devices in c ?
What should I install to use namespace Windows::Devices in c ?

Time:11-28

Now I am going to connect to device using bluetooth, so I have got some source code. It uses namespace Windows::Devices, but my visual studio gives me compile error.

using namespace Windows::Devices;

I guess I have to install some packages additionally, but I am not sure what I have to install. If anyone knows, please help me.

CodePudding user response:

Since the question is tagged 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), generated into namespaces such as Windows::Devices.

It's common for a project to generate the headers containing the projected types on the fly, that can then be included like any other header. A project created using the C /WinRT VSIX extension does that. Those projects have a reference to the Microsoft.Windows.CppWinRT NuGet package that contains the code generator, as well as project properties to drive it during a build.

Previously, the header files containing the projected C /WinRT types had been delivered through the Windows SDK. They are still part of the SDK, and can be used by client code, even though it's preferable to use the NuGet package instead. You'll find the Windows.Devices.h header file under %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt, so to use this namespace, that's the file you'll need to include.

  • Related