include TimerAPI DWORD initialTime 0x00 timePassed 0x00 VOID CALLBACK

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "TimerAPI.h"
DWORD initialTime = 0x00, timePassed = 0x00;
VOID CALLBACK TimerCallback( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime )
{
if (!initialTime) initialTime = dwTime;
else timePassed = dwTime - initialTime;
printf("%u\n",timePassed);
}
int main(int argc, char * argv[])
{
MSG msg;
UINT timerId = SetTimer(NULL, 0, 600, &TimerCallback);
if (timerId)
{
while (GetMessage(&msg, NULL, 0, 0) && timePassed < 5200)
{
DispatchMessage(&msg);
}
KillTimer(NULL, timerId);
}
return 0;
}