怎么样获得从启动到目前的时间?(30分)

  • 主题发起人 主题发起人 孔明.net
  • 开始时间 开始时间

孔明.net

Unregistered / Unconfirmed
GUEST, unregistred user!
怎么样获得从启动到目前的时间?
 
starttime := now();
//放在程序启动时
nowtime := now();
//现在时间
再参照下面的解决方法。
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1131624
 
gettickcount
直接取就可以了
 
用GetTickCount这个API函数即可,关于这个函数的描述:
----------------------------------------------------------------------------
The GetTickCount function retrieves the number of milliseconds that have
elapsed since Windows was started.
DWORD GetTickCount(VOID)
Parameters
This function has no parameters.
Return Values
If the function succeeds, the return value is the number of milliseconds that
have elapsed since Windows was started.
Remarks
The elapsed time is stored as a DWORD value. Therefore, the time will wrap
around to zero if Windows is run continuously for 49.7 days.
Windows NT: To obtain the time elapsed since the computer was started,
look up the System Up Time counter in the performance data in the registry key HKEY_PERFORMANCE_DATA. The value returned is an 8 byte value.
 
HEHE,一个gettickcount引来无数抢分的,可惜我晚了一步
 
好可惜,来晚咯.
就是用GetTickCount,得到的是启动到现在的微秒数.
 
GetTickCount不一定准的。 如果你GetTickCount取得的是100, 你怎么知道机器运行了100ms 还是49.7天另100ms?
应当取注册表
 
to:Pearl.,
请问读注册表哪里?
 
look up the System Up Time counter in the performance data
in the registry key HKEY_PERFORMANCE_DATA.
The value returned is an 8 byte value.
 
接受答案了.
 

Similar threads

回复
0
查看
742
不得闲
回复
0
查看
703
不得闲
回复
0
查看
830
不得闲
后退
顶部