sohel14_cse_ju
sohel14_cse_ju

Reputation: 2521

Set System Time programmatically

Is it possible to set the system date and time from an uwp app? I was just trying a simple way. But this throws an error.

void winrt::Calender::implementation::MainPage::datePicker_DateChanged(winrt::Windows::UI::Xaml::Controls::CalendarDatePicker const& sender, winrt::Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs const& args)
{
    Windows::System::DateTimeSettings::SetSystemDateTime(args.NewDate().GetDateTime());
}

WinRT originate error - 0x80004001 : 'Not implemented'.

Upvotes: 1

Views: 130

Answers (1)

Chuck Walbourn
Chuck Walbourn

Reputation: 41127

This API is only implemented for IoT devices and requires the systemManagement capability.

Setting the system time requires administrator rights on Desktop in any case, so this is not something a UWP can generally do.

If you want to know why system time is protected in this way, see Microsoft Docs

Upvotes: 1

Related Questions