Windows 7报告负正常运行时间 [英] Windows 7 Reports Negative Uptime

查看:110
本文介绍了Windows 7报告负正常运行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

我有一个用VB.NET 2008编写的应用程序,它使用非常简单的Environment.TickCount命令来获取PC的正常运行时间.

I have an application I have written in VB.NET 2008 and it uses the very simple command Environment.TickCount to get the PC's uptime.

它可以在除一个Windows 7系统之外的所有计算机上正常工作.此系统报告一个负数,例如:-1584704440

It works properly in every computer except one Windows 7 system. This one system reports a negative number, for example: -1584704440

我一直无法找到任何可能发生这种情况的信息.我的搜索结果只是增加了如何读取正常运行时间或UTC问题的信息,我必须纠正该问题. PC上的日期和时间是正确的,只是正在报告正常运行时间 错误的.

I have been unable to find any information as to why this might occur. My search results are only turning up how to read the uptime or issues with UTC, and I must correct the problem. The date and time on the PC are correct, it's just the uptime being reported wrong.

谢谢!

推荐答案

亲爱的KyferEz,

Dear KyferEz,

并不是说我对Visual Basic确实有一个很大的想法,但是就我记得而言,GetTickCount函数以毫秒为单位返回了一个DWord,这意味着负值原则上是不可能的.回报期约7周.负面的解释 在我看来,只有当试图用带符号的整数(我相信在VB中命名为long,或&")来捕获此DWord时,计算机才有可能,但同时必须启动,因为大于3个半星期没有关机.如果两者都 这是有效的,您将获得负值.如果可能的话,最好使用一个无符号的长整数,如果可能的话,甚至可以使用64位的整数(这里不需要64位,但是如果您还想使用这些时间值执行简单的计算,那就更好了),那么您的 结果不能为负.

not that I really had a big idea of Visual Basic, but the GetTickCount function as far as I remember returns a DWord in milliseconds, what means a negative value is principally impossible. The span of the return covers ~7 weeks. A negative interpretation here to me seems to be possible only when this DWord is tried to be caught by a signed integer (named long in VB I believe, or "&") while the computer but at the same time must be up since more than 3 and a half weeks without shutdown. If both this is valid you will harvest a negative value. If possible better use an unsigned long integer, maybe even a 64 bit one if available (64 bit is not needed here, but better if you also wanted to perform simple calculations with these time values), then your result can not be negative.

最诚挚的问候,
sbit.

Best regards,
sbit.


这篇关于Windows 7报告负正常运行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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