通过TCP / IP,没有服务器两台PC之间的同步时间两台、服务器、时间、TCP

2023-09-06 07:39:41 作者:镜花水月

我有两个电脑通过局域网连接。当用户改变在一个时间(通过我的应用程序),我想时间上的第二个过于更新(或第二台机器可以轮询第一)。有没有服务器,没有网络。什么是做到这一点的最好方法是什么?

I've got two PCs connected by LAN. When the user alters the time (via my application) on one, I'd like the time on the second to be updated too (or the second machine could poll the first). There's no server, no internet. What's the best way to do this?

操作系统:XP嵌入式 框架:净3.5

OS: XP embedded. Framework: .Net 3.5

推荐答案

一个低技术的解决方案可能是要执行的命令 NET TIME \\ [OtherPC] / SET 上需要的机器进行更新

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.

请注意,我只试图在正常的Windows机器,但我想这也将工作嵌入。

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

编辑:环顾四周,好像XP嵌入式操作系统可以支持WMI,如果这样做,它确实具有的 的Win32_OperatingSystem类,它的的 SetDateTime 方法,您的应用程序可能会作出这样的呼叫远程PC,你可以避免轮询的变化。

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.