SNTP server validation

I wrote a small application that would provide a user a way to enable and set an SNTP server. Everything is working correctly as I first modify the [HKEY_LOCAL_MACHINE\Services\Timesvc] registry key then send IOCTL_SERVICE_REFRESH via the DeviceIoControl function. Now I need to find a way to validate whether the SNTP server from the user input is correct or not. Is there a way to validate or be notified if the synchronization with an SNTP server was successful or not?


Just for my information, will the DeviceIoControl() not tell whether the “IOCTL_SERVICE_REFRESH” operation is successful?

Hello @sahil.tx,

Yes it does, however the operation still returns successfully whether or not the SNTP server defined in the registry key is correct.


There does not seem to be a direct and easy way to validate the server.

I tried with the following command in cmd

services -d refresh NTP0:
and this gave the output on debug as
"RTCSync: Completed.
RTC Time set (17.07.2020 07:26:46)

The same thing happens when you sync using the application (using DeviceIoControl) but nothing happens (no error) in case of wrong server or server not available.
There can be more than 1 reason for time not syn or wrong time updated

These workarounds could be helpful

  1. Save the current date and set a wrong date (maybe 0x00)
  2. You can try pinging to check if the server is not down after the user entered the server
  3. Force SNTP sync and start a timer which will be used to compare the time later
  4. Check whether time has been updated or not by comparing the updated time/current time and the saved time(compare the difference with the timer clock).

Let me know if these are useful to you.