要在Windows的Server里实现一个定时器,但是server是没有窗口的,回调函数的窗口怎么理解?
VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)UINT SetTimer(
  HWND hWnd,              // handle of window for timer messages
  UINT nIDEvent,          // timer identifier
  UINT uElapse,           // time-out value
  TIMERPROC lpTimerFunc   // address of timer procedure
);
的窗口句柄怎么处理?

解决方案 »

  1.   

    直接置NULL,在自定义的TIMERPROC里处理
      

  2.   

    MSDN里关于WM_TIMER的说明:
         You can process the message by providing a WM_TIMER case in the window procedure. Otherwise, DispatchMessage will call the TimerProc callback function specified in the call to the SetTimer function used to install the timer
      

  3.   

    UINT SetTimer(
      HWND hWnd,              // handle of window for timer messages
      UINT nIDEvent,          // timer identifier
      UINT uElapse,           // time-out value
      TIMERPROC lpTimerFunc   // address of timer procedure
    );
    这里的hWnd只是说明你个定时器应用到这个窗口中,系统将产生在消息分发给这个窗体,如果窗口参数为NULL, 就是自己来处理WM_TIME消息。
      

  4.   

    必须要有窗口才行,你可以建一个隐藏窗口,也可以使用多媒体定时器(timeSetEvent)来代替它。