Windows API to trigger the time synchronization

后端 未结 2 646
小蘑菇
小蘑菇 2021-02-05 17:31

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 clicki

2条回答
  •  生来不讨喜
    2021-02-05 17:52

    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 
    
    ...
    
    system("w32tm /resync /nowait");
    

    Take a look at w32tm documentation for further options.

提交回复
热议问题