如何用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