1. 首页
  2. 编程语言
  3. C++ 
  4. 使用SetTimerWindows无窗口计时器的实现
下载地址
用户评论
DuDu_55684 2024-12-27 06:08:59

无用,很简单的代码使用SetTimer,Windows无窗口计时器的实现 #include #include #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; }