检查Windows是否配置为使用时间服务器 [英] Check whether Windows is configured to use a time server
本文介绍了检查Windows是否配置为使用时间服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿伙计们,
我想知道有没有办法检查Windows是否配置为与时间服务器同步。
我试图检查一个时间服务器并匹配当前的机器时间,但是这不起作用,所以从Windows接收时间服务器设置会很棒。任何人?
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?
推荐答案
假设您要从代码中检查内置服务状态,您可以 call [ ^ ]w32tm
(后面的服务是W32Time
)并解析结果。请注意,某些操作需要提升权限。
第三方NTP / SNTP客户端可能拥有自己的API。
所以最后,如果您只需要知道当前时间是否处于snyc状态,那么您在检查时间服务器时并没有走错路。但是你需要做正确的事情,使用NTP / SNTP客户端组件,如下所述:用于C#和VB.NET的SNTP客户端 [ ^ ]。有了它,您可以检查本地时钟偏移。如果它低于一定水平(假设是1s),那你很好。
如果你不想从代码中做到这一切,那么你就是错误的市场。这是一个编码器论坛。这个想法仍然是一样的......
Assuming you want to check the built-in service status from code, you can call[^]w32tm
(the service behind isW32Time
) 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...
这篇关于检查Windows是否配置为使用时间服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文