How to set system time in Windows 10 IoT?

后端 未结 8 2498
星月不相逢
星月不相逢 2020-12-31 05:12

Is there a way to set system time from my app running on a Raspberry Pi 2 in Windows 10 IoT Core Insider Preview?

This doesn\'t work for lack of kernel32.dll

<
8条回答
  •  渐次进展
    2020-12-31 05:43

    1-New Universal Project
    2-Add Reference>Extensions>Windows IOT Extensions for UWP
    3- Put a button, a datepicker and a timepicer control on your MainPage.xaml
    and

    private void buttonSetSystemDatetime_Click(object sender, RoutedEventArgs e)
            {
                DateTimeOffset dto = datePicker1.Date+ timePicker1.Time;
                Windows.System.DateTimeSettings.SetSystemDateTime(dto);
            }
    

    4- in poject settings> set your target version and min version 10.0; build 16299
    5- double click appxmanifest > Capabilities > check ON "System Management"

    6- run app in IOT and press button. than return to default app. voila! system datetime changed.

    note: rather to set it everytime. I offer you buy a cheap rtc (real time clock) module. (also needs extra coding)

提交回复
热议问题