使用 Windows API 的 NTP 客户端
我正在维护一个遗留系统(.NET 之前的系统)。有没有办法使用 Windows API 从 NTP 服务器获取时间?如果做不到这一点,我可能可以使用 .NET 创建一个 COM 对象来完成此操作,但我宁愿不这样做。
I'm maintaining a legacy system (pre .NET). Is there any way to fetch the time from an NTP server using the Windows API? Failing that, I could probably create a COM object with .NET to do it, but I would rather not go to that effort.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这当然有可能。除非您雄心勃勃,否则从工作源代码开始可能是最简单的。我会选择 Terje Mathisen 的端口,但这可能是因为我已经通过 Usenet (comp.lang.asm.x86) 了解 Terje 多年了——其他端口可能也非常好。
Yes, it's certainly possible. Unless you're quite ambitious, it's probably easiest to start from working source code. I'd go for Terje Mathisen's port, but that's probably because I've known Terje via Usenet (comp.lang.asm.x86) for years -- the other ports are probably perfectly good too.
我发现的最好的来源是 http://www.dataman.ro/?page_id=39。
但是,我倾向于通过 NetRemoteTOD.只要在本地时间服务器计算机上正确配置,Windows 就会自动与 NTP 服务器保持日期同步。然后,如果他们的互联网访问中断,我仍然能够获取“标准”时间。
The best source that I found was http://www.dataman.ro/?page_id=39.
However, I'm leaning toward using the time from a server on the local LAN/WAN, via NetRemoteTOD. Windows is supposed to keep the date synchronized from an NTP server automatically, as long as its configured properly on their local time server machine. Then if their Internet access goes down, I'll still be able to fetch the "standard" time.