Purpose
DosTmrQueryFreq queries the frequency of the high resolution timer. To get the high resolution time interval in seconds, subtract two 64 bit times and divide by the frequency.
Syntax
#define INCL_DOSPROFILE #include os2.h>
APIRET APIENTRY DosTmrQueryFreq
Parameters
freq(PQWORD) output
Returns
ulrc (APIRET) returns
DosTmrQueryFreq returns one of the following values
87
Example Code
void int3(void);
int main(int argc, char *argv[], char *envp[])
{
QWORD start_time;
QWORD end_time;
QWORD interval;
ULONG freq;
APIRET rc;
rc=DosTmrQueryTime( start_time);
printf("DosTmrQueryTime rc=%u time=0x%08x%08x\n", rc,start_time.ulHi,start_time.ulLo);
DosSleep(100);
printf("Sleeping 100ms\n");
rc=DosTmrQueryTime( end_time);
printf("DosTmrQueryTime rc=%u time=0x%08x%08x\n", rc,end_time.ulHi,end_time.ulLo);
rc=DosTmrQueryFreq( freq);
printf("DosTmrQueryFreq rc=%u freq=%uHz\n",rc,freq);
interval.ulLo = end_time.ulLo - start_time.ulLo;
interval.ulHi = (end_time.ulLo >= start_time.ulLo) ?
end_time.ulHi - start_time.ulHi
end_time.ulHi - start_time.ulHi - 1;
printf("Time interval=0x%08x%08x units=%uns\n",interval.ulHi,interval.ulLo,1000000000/freq);
if (interval.ulHi == 0) printf("Appox. %uns\n",interval.ulLo*(1000000000/freq));
return 0;
}