windows 如何更新日期和时间控制面板以匹配 W32Time 服务配置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1509928/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 13:13:31  来源:igfitidea点击:

How can I update the Date and Time control panel to match the W32Time service configuration?

windowstime

提问by Matthew Xavier

I have a client/server application for which it is beneficial to have the PC clocks on the client and server synchronized. I want my setup program to offer an option to configure the W32Time service automatically.

我有一个客户端/服务器应用程序,它有利于让客户端和服务器上的 PC 时钟同步。我希望我的安装程序提供一个选项来自动配置 W32Time 服务。

I have found sufficient documentation to configure the service's registry entries (principally here), and I have confirmed that after restarting the service, the clock on my test client PC is corrected to match the clock on my test server PC. However, if I look at the Date and Time control panel on the client PC, it still indicates that the clock is set to be synchronized to time.windows.com (the default) instead of the test server PC.

我找到了足够的文档来配置服务的注册表项(主要在这里),并且我已经确认在重新启动服务后,我的测试客户端 PC 上的时钟被更正以匹配我的测试服务器 PC 上的时钟。但是,如果我查看客户端 PC 上的日期和时间控制面板,它仍然表明时钟设置为同步到 time.windows.com(默认)而不是测试服务器 PC。

How can I trigger the Date and Time control panel to update itself to match the time service configuration? Or failing that, where can I find the control panel's configuration stash and update it myself?

如何触发日期和时间控制面板更新自身以匹配时间服务配置?或者失败了,我在哪里可以找到控制面板的配置存储并自己更新?

回答by Matthew Xavier

Digging around in the registry, I have found an answer. The Date and Time control panel stores a list of time servers under its own registry location:

在注册表中挖掘,我找到了答案。日期和时间控制面板在其自己的注册表位置存储时间服务器列表:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers

Regardless of the actual configuration of W32Time, the control panel will use this information when showing its UI. Each value under the key has a numeric name and is of type REG_SZ containing the hostname of a time server. The (Default) value is the number of the currently-selected server in the control panel.

无论 W32Time 的实际配置如何,控制面板在显示其 UI 时都会使用此信息。键下的每个值都有一个数字名称,并且属于包含时间服务器主机名的 REG_SZ 类型。(默认)值是控制面板中当前选择的服务器的编号。

Therefore, I needed to add a new string value for my time server and set its number in the (Default) value.

因此,我需要为我的时间服务器添加一个新的字符串值,并在(默认)值中设置其编号。