2017/09/16

C#.Net Windows 10 IoT Core 實現關機重開機功能

將「Windows IoT Extensions for the UWP」加入參考


Package標籤內加入
xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10"

IgnorableNamespaces新增
iot

Capabilities內加入
<iot:Capability Name="systemManagement" />




程式碼:

//立即關機
ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, new TimeSpan(0));
//立即重新開機
ShutdownManager.BeginShutdown(ShutdownKind.Restart, new TimeSpan(0));

參考資料:
https://docs.microsoft.com/en-us/uwp/api/windows.system.shutdownmanager
https://msdn.microsoft.com/en-us/library/windows/apps/mt694883.aspx

沒有留言:

張貼留言