重温WIN32 API ------ SetTimer()无窗口调用方式

 

#include <stdio.h> 
#include <windows.h> 

#define  IDT_TIMER  100

void CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
{
 SYSTEMTIME st;

 GetLocalTime(&st);
    printf("%2d:%2d:%2d.%3d hello!/n", st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
}

int main(int argc, char* argv[])
{

    int iret = SetTimer(NULL, IDT_TIMER, 1000, (TIMERPROC)TimerProc);

    MSG msg;
    while (1) 
    {
        GetMessage(&msg, NULL, 0, 0);
        DispatchMessage(&msg);        
    }    
   return 0;
}
 


 

你可能感兴趣的:(重温WIN32 API ------ SetTimer()无窗口调用方式)