Windows API 触发时间同步 [英] Windows API to trigger the time synchronization
问题描述
是否有 Windows API 可以实现等效于单击日期和时间属性"/Internet 时间"选项卡(通过双击任务栏中的时钟打开)中的立即更新"按钮的效果?
有没有办法监控时间同步什么时候被windows触发,什么时候成功或者失败?
时间服务没有公开 API,但要触发时间同步,您可以使用 w32tm
命令行工具.
在 C/C++ 中,你可以这样做:
include ...system("w32tm/resync/nowait");
查看 w32tm 文档,了解更多选项.>
Is there a windows API that would achieve the equivalent of clicking the "Update now" button in the "Date and time properties"/"Internet time" tab (opened by double clicking the clock in the taskbar)?
Is there a way to monitor when the time synchronization is triggered by windows and when it succeeds or fails?
There is no API exposed by the time service, but to trigger a time synchronization you can use the w32tm
command line tool.
In C/C++ you can do something like this:
include <process.h>
...
system("w32tm /resync /nowait");
Take a look at w32tm documentation for further options.
这篇关于Windows API 触发时间同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!