Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey guys,

I want to know it there's a way to check whether Windows is configured to synchronize with a time server or not.

I've tried to check a timeserver and match the current machine time, but this doesn't do the trick, so just receiving the time server setting from windows would be great. Anyone?
Posted

1 solution

Assuming you want to check the built-in service status from code, you can call[^] w32tm (the service behind is W32Time) and parse the result. Please note, that some operations require elevated privileges.

Third party NTP/SNTP clients might have their own API.

So finally, if you only need to know if your current time is in snyc or not, you were not on a wrong path with checking against a time server. But you need to do it right, be using an NTP/SNTP client component, like on described here: An SNTP Client for C# and VB.NET[^]. With that you can check your local clock offset. If it is below a certain level (let's say 1s), you are good.

If you don't want to do this all from code, than you are on the wrong market. This is a coder forum. Still the idea is the same...
 
Share this answer
 
v4
Comments
Sergey Alexandrovich Kryukov 6-Oct-14 18:14pm    
5ed.
—SA
Zoltán Zörgő 6-Oct-14 18:16pm    
Thank you.
BillWoodruff 6-Oct-14 21:02pm    
+5
Zoltán Zörgő 7-Oct-14 2:19am    
Thank you
Eduard Keilholz 7-Oct-14 3:06am    
Exactly what I was looking for, 5-ed and accepted, thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900