The timer queue timers seem to work essentially like the other timers, and have the same 10 or 15.6 ms resolution.
;==============================================================================
include \masm32\include\masm32rt.inc
include \masm32\include\winmm.inc
includelib \masm32\lib\winmm.lib
;==============================================================================
;-----------------------------------------------------------------------------
; This macro more or less duplicates the functionality of the BASIC language
; TIMER function, returning the elapsed seconds since the performance counter
; started counting as a REAL8 value with an effective resolution of a few
; microseconds.
;-----------------------------------------------------------------------------
timer MACRO
IFNDEF _timer_pc_frequency_
.data
align 8
_timer_pc_frequency_ dq 0
_timer_pc_count_ dq 0
_timer_elapsed_seconds_ dq 0
_timer_initialized_ dd 0
.code
ENDIF
.IF _timer_initialized_ == 0
invoke QueryPerformanceFrequency, ADDR _timer_pc_frequency_
inc _timer_initialized_
.ENDIF
invoke QueryPerformanceCounter, ADDR _timer_pc_count_
fild _timer_pc_count_
fild _timer_pc_frequency_
fdiv
fstp _timer_elapsed_seconds_
EXITM <_timer_elapsed_seconds_>
ENDM
;==============================================================================
.data
r8 REAL8 0.0
t1 REAL8 0.0
hTimerQueue dd 0
phNewTimer dd 0
param dd 123
.code
;==============================================================================
TimerProc proc lpParameter:PVOID, junk:DWORD
fld timer()
fsub t1
fstp r8
printf("%1.4f s\n", r8)
fld timer()
fstp t1
ret
TimerProc endp
;==============================================================================
start:
;==============================================================================
invoke Sleep, 3000
invoke CreateTimerQueue
mov hTimerQueue, eax
.IF eax == 0
printf("CreateTimerQueue error %s\n",LastError$())
.ENDIF
;invoke timeBeginPeriod, 1
invoke CreateTimerQueueTimer, addr phNewTimer, hTimerQueue,
TimerProc, addr param,
1, 1, 0
.IF eax == 0
printf("CreateTimerQueueTimer error %s\n",LastError$())
.ENDIF
invoke Sleep, 2000
;invoke timeEndPeriod, 1
invoke DeleteTimerQueueEx, hTimerQueue, INVALID_HANDLE_VALUE
.IF eax == 0
printf("DeleteTimerQueueEx error %s\n",LastError$())
.ENDIF
inkey
exit
;==============================================================================
end start