将系统日期更改为当前日期 [英] change system date to current date

查看:59
本文介绍了将系统日期更改为当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过我的c#应用程序更改系统日期,

因为cmos电池有问题。

所以我怎么能得到当前日期?



而不是改变cmos电池...

i want to change system date through my c# application,
as there is problem with cmos battery.
so how could i get current date ?
?
and not to change cmos battery...

推荐答案

如果你不能相信CMOS电池,那么你需要从互联网上获取时间。您可以使用许多互联网时间服务器:Google可以帮助您,只需查找NIST或NTP服务器。



设置系统时钟虽然是特权操作 - 这意味着您需要管理员权限才能执行此操作。代码很简单: http://msdn.microsoft.com/en- us / library / ms172517(v = vs.90).aspx [ ^ ] - 但它可能更像是你想要的PITA。



我?我要更换电池 - 它们并不昂贵,旧的漏电池会严重损坏PCB!
IF you can't trust the CMOS battery, then you need to get the time from the internet. There are a number of internet time servers which you can use: Google can help you, just look for NIST or NTP servers.

Setting the system clock though is a privileged operation - which means you need admin permissions to do it. The code is simple: http://msdn.microsoft.com/en-us/library/ms172517(v=vs.90).aspx[^] - but it may be more of a PITA that you want.

Me? I'd change the battery - they aren't expensive and old leaky batteries can do serious damage to the PCB!


这篇关于将系统日期更改为当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆