0
votes

I'm currently playing around with Windows IoT Core and I'm trying to develop a C++ based UWP app for Raspberry Pi 3b. I want to reboot/shutdown the Pi from inside the app but I'm not sure how I can do this.

The UWP api reference lists the C# Windows.System which corresponds to C++ Windows::System. But it seems that not all classes are available in C++. The UWP samples (C#) utilize the ShutdownManager class for reboot and shutdown but it is not existing in the C++ namespace. Now I'm not sure how I'm supposed to implement this functionality by utilizing the API. Are there any other possibilities to solve this for C++?

Solution: I was missing the Windows IoT Extensions for the UWP. These have to manually added in Visual Studio by right clicking the Project, then Add -> Reference -> Universal Windows -> Extensions. Now I have access to the namespace and was able to reboot and shutdown my device.

1

1 Answers

0
votes

But it seems that not all classes are available in C++.

Did it mean when you built the C++ UWP project, it can not build successfully, or when you ran the app on device, an exception appeared?

The ShutdownManager API is available in C++, indeed it is included in Windows::System namespace, please refer to this document. And please note that:

This API requires the use of the IoT systemManagement capability, and the inclusion of iot in the IgnorableNamespaces list. Users can add the following to their Package.appmanifest: , and add iot to their existing list of IgnorableNamespaces.

Following code works fine on my device.

TimeSpan ts;
ts.Duration = 1000;
ShutdownManager::BeginShutdown(ShutdownKind::Shutdown, ts);