maghcc
asked on
Absolute Time measure in milliseconds on pocket pc
Hi Expert :
I need to measure absolute time until milliseconds on pocket pc device.
Because I want to measure time to compare with other device.
When I using GetSystemTime() , the wMilliseconds field always return zero.
When I using function : GetTickCount() or timeGetTime() ,
they are all reterive the time elapsed since the system started.
Is any idea can get current time that time units until milliseconds?
My platform is pocket pc2003 , using VC++ development
Thanks very much!
mag
I need to measure absolute time until milliseconds on pocket pc device.
Because I want to measure time to compare with other device.
When I using GetSystemTime() , the wMilliseconds field always return zero.
When I using function : GetTickCount() or timeGetTime() ,
they are all reterive the time elapsed since the system started.
Is any idea can get current time that time units until milliseconds?
My platform is pocket pc2003 , using VC++ development
Thanks very much!
mag
ASKER
Hi Export:
How to use them togother?
Does GetTickCount() reterive the time elapsed since the system started?
Is like this ?
GetSystemTime() + GetTickCount() ??
Thanks very much !
Mag
How to use them togother?
Does GetTickCount() reterive the time elapsed since the system started?
Is like this ?
GetSystemTime() + GetTickCount() ??
Thanks very much !
Mag
If you are very particular then GetTickCount also is not going to work,.. Check out the implmentation for advanced tick count in this thread
https://www.experts-exchange.com/questions/20672393/Windows-System-Tick-Time-Resolution-Networking-Select-loop.html
~Hemanth
https://www.experts-exchange.com/questions/20672393/Windows-System-Tick-Time-Resolution-Networking-Select-loop.html
~Hemanth
// initialization
startTime = GetSystemTime();
while(startTime == GetSystemTime()); // wait till time changes (second changes)
refTickCount = GetTickCount(); // get refernce tick count
// usage
tmTime = GetSystemTime(); // without ms
time_ms = (GetTickCount() - refTickCount) % 1000; // modulo to get
tmTime2 = GetSystemTime();
if(tmTime != tmTime2) { // has time hanged in the meantime ?
time_ms = 0;
};
tmTime2.wMiliseconds += time_ms;
More or less
startTime = GetSystemTime();
while(startTime == GetSystemTime()); // wait till time changes (second changes)
refTickCount = GetTickCount(); // get refernce tick count
// usage
tmTime = GetSystemTime(); // without ms
time_ms = (GetTickCount() - refTickCount) % 1000; // modulo to get
tmTime2 = GetSystemTime();
if(tmTime != tmTime2) { // has time hanged in the meantime ?
time_ms = 0;
};
tmTime2.wMiliseconds += time_ms;
More or less
Should be:
tmTime2.wMiliseconds = time_ms;
tmTime2.wMiliseconds = time_ms;
or maybe better (if it works on your platform)
// initialization
startTime = GetSystemTime();
while(startTime == GetSystemTime()); // wait till time changes (second changes)
refTickCount = GetTickCount(); // get refernce tick count
// usage (simply add elapsed ms to startTime)
SystemTimeToFileTime(&star tTime, &fileTime);
// * 10000 because FILETIME is expressed in 100 ns units
*(ULARGE_INTEGER *)&fileTime += (GetTickCount() - refTickCount) * 10000;
FileTimeToSystemTime(&file Time, &resTime);
// initialization
startTime = GetSystemTime();
while(startTime == GetSystemTime()); // wait till time changes (second changes)
refTickCount = GetTickCount(); // get refernce tick count
// usage (simply add elapsed ms to startTime)
SystemTimeToFileTime(&star
// * 10000 because FILETIME is expressed in 100 ns units
*(ULARGE_INTEGER *)&fileTime += (GetTickCount() - refTickCount) * 10000;
FileTimeToSystemTime(&file
ASKER
Hi Expert:
I deeply appreciate your help.
But have one problem. Here is my code segment.
SYSTEMTIME startTime;
SYSTEMTIME secondTime;
DWORD refTickCount = 0;
// initialization
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) {
GetSystemTime(&startTime);
while (1){
GetSystemTime(&secondTime) ;
if ((startTime.wMinute != secondTime.wMinute) || (startTime.wSecond != secondTime.wSecond))
break;
}
refTickCount = GetTickCount(); // get refernce tick count
some code statements;
}
DWORD WINAPI DoWaitNotifThread(PVOID pArg)
{
FILETIME fileTime;
SYSTEMTIME resTime;
// usage (simply add elapsed ms to startTime)
SystemTimeToFileTime(&star tTime, &fileTime);
// * 10000 because FILETIME is expressed in 100 ns units
*(ULARGE_INTEGER *)&fileTime += (GetTickCount() - refTickCount) * 10000;
FileTimeToSystemTime(&file Time, &resTime);
SystemTimeToFileTime(&star tTime, &fileTime);
}
Is FILETIME structure by declare in fileTime variables ?
If using FILETIME structure , I don't know what fields either dwLowDateTime or dwHighDateTime which be used?
Thanks very much!!
Mag
I deeply appreciate your help.
But have one problem. Here is my code segment.
SYSTEMTIME startTime;
SYSTEMTIME secondTime;
DWORD refTickCount = 0;
// initialization
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) {
GetSystemTime(&startTime);
while (1){
GetSystemTime(&secondTime)
if ((startTime.wMinute != secondTime.wMinute) || (startTime.wSecond != secondTime.wSecond))
break;
}
refTickCount = GetTickCount(); // get refernce tick count
some code statements;
}
DWORD WINAPI DoWaitNotifThread(PVOID pArg)
{
FILETIME fileTime;
SYSTEMTIME resTime;
// usage (simply add elapsed ms to startTime)
SystemTimeToFileTime(&star
// * 10000 because FILETIME is expressed in 100 ns units
*(ULARGE_INTEGER *)&fileTime += (GetTickCount() - refTickCount) * 10000;
FileTimeToSystemTime(&file
SystemTimeToFileTime(&star
}
Is FILETIME structure by declare in fileTime variables ?
If using FILETIME structure , I don't know what fields either dwLowDateTime or dwHighDateTime which be used?
Thanks very much!!
Mag
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thans so much!
Mag
Mag
Why not calculate it by using both GetTickCount and GetSystemTime together?
David Maisonave (Axter)
Cheers!