2

我有两台电脑通过局域网连接。当用户更改一个时间(通过我的应用程序)时,我希望第二个时间也可以更新(或者第二个机器可以轮询第一个)。没有服务器,没有互联网。最好的方法是什么?

操作系统:XP 嵌入式。
框架:.Net 3.5

4

3 回答 3

1

If you can't use NTP server you have to write it by yourself.

  1. The two application both implements a WCF service and are one client of the other;
  2. The application that have its local time modified notifies the other and sends a DateTime;
  3. The application that receives the updated DateTime changes local time (but be aware that your application will need higher privilege to do this because you have to do it via unmanaged code);

If you don't need much precision you are done. If you need greater precision, you will need to estimate the time lost between the data sending and arrivals and is not trivial.

于 2010-11-29T14:12:53.083 回答
1

A low tech solution might be to execute the command NET TIME \\[OtherPC] /SET on the machine that needs to be updated.

You could possibly set the machine up to call this at a certain interval.

Please note, I've only tried it on normal windows machines, but I think it would also work on embedded.

Edit: Looking around it seems like XP Embedded might support WMI, if it does and it does have the Win32_OperatingSystem class and it's SetDateTime method, your app could make that call to the remote pc and you could avoid having to poll for changes.

于 2010-11-29T14:13:49.683 回答
0

是否可以将其中一台机器指定为 NTP 服务器?因此使用标准的 NTP 服务器系统,因此您不必自己编写。

虽然我不熟悉 XPe 这个链接有时间吗?似乎有所有必需的流行语

于 2010-11-29T14:24:55.300 回答