Forum Cross Platform with Xamarin

How to get system Time settings property through an UWP Xamarin application?

afsaltafsalt Member ✭✭

I have a Xamarin application and I need to check whether the Date&Time setting has enabled the "Set Automatically" property or not.

I need to validate the current Date&Time uses NTP time or not?

Steps for accessing NTP through the registry as follows(Normal windows not from APP)

1- Press the Windows logo key + R to open the Run box. Type Regedit and hit Enter.

2- When the Registry Editor opens, navigate to the following key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters to check Type property value is NTP or NoSync

3- In order to enable or disable “Set Time Zone Automatically” in Windows 10, navigate to the following key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\tzautoupdate

4- Double-click the 32-bit DWORD “Start” in the right pane. Set its value data to 3 if you want to make Windows 10 set time zone automatically. If you want to disable “Set Time Zone Automatically” in Windows 10, just set the value to 4.

I need to validate either 2 or 3 values through Xamarin UWP apps, whether The date&time setting is set to Automatically or not.

I am attaching the screenshots and Please refer to this link for how we can get the Date&Time settings through Normal windows,
I need to check this one through Xamarin UWP application.
If it is enabled I need to perform an operation otherwise I need to display an Alert that showing to "change the Date&Time setting and try again later".

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    I need to validate the current Date&Time uses NTP time or not?

    You could get the time value from the application, then compare with the time of the NTP server to check if two values are the same.

    To query the NTP server, check the link:
    https://stackoverflow.com/questions/1193955/how-to-query-an-ntp-server-using-c

  • afsaltafsalt Member ✭✭

    @Jarvan I need to check whether Set Automatically property enabled or disabled from Xamarin app through code.

  • JarvanJarvan Member, Xamarin Team Xamurai

    It is not possible to determine what that system setting is directly, the work around is to validate against a NTP server.

Sign In or Register to comment.