vc获取计算机时间,如何用vc++获取系统时间和程序运行时间(How to obtain system time and program running time with vc++).doc...

如何用vc++获取系统时间和程序运行时间(How to obtain system time and program running time with vc++)

Title: how to get system time and program running time with vc++

Provenance: the cause of spring

Time: Mon, 22, Jun, 2009, 17:34:26, +0000

Author: xiechunye

Address: /read.php/612.htm

Content:

How does Q: get the time? What is the accuracy?

A:

1 use time_t time (time_t * timer) to be accurate to seconds

Calculate the time difference using double difftime (time_t, Timer1, time_t, timer0)

2 use clock_t clock () to get CPU time accurate to 1/CLOCKS_PER_SEC seconds

3, using DWORD GetTickCount () to get the system running time accurate to milliseconds

4, if you use the CTime class of MFC, you can use CTime:: GetCurrentTime () to be accurate to seconds

5 to obtain high precision time, you can use

BOOL QueryPerformanceFrequency (LARGE_INTEGER *lpFrequency) gets the frequency of the counter of the system

BOOL QueryPerformanceCounter (LARGE_INTEGER *lpPerformanceCount) gets the value of the counter

Then the difference between the two counters is divided by Frequency to get the time.

6, there are also the methods mentioned in David's article:

Multimedia Timer Functions

The, following, functions, are, used, with, multimedia, timers.

TimeBeginPeriod/timeEndPeriod/timeGetDevCaps/timeGetSystemTime

TimeGetTime/timeKillEvent/TimeProc/timeSetEvent has high accuracy

The Q:GetTickCount () function is said to be a millisecond count, is it true, or is it accurate to 55 milliseconds?

A:

GetTickCount () and GetCurrentTime () are only accurate to 55ms (1 tick is 55ms). If you want to be accurate to milliseconds, you should use either the timeGetTime function or the QueryPerformanceCounter function. Specific examples can refer to QA001022, "use high precision timers in VC++", "QA001813", "how to achieve accurate timing in Windows" and "QA004842", timeGetTime function delay is not allowed".

How does Q:vc++ get system time and what type of variable is the return value?

GetSystemTime return to the Green Weizhi s

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值