在DLL中,没有窗体,而且不用线程,能否实现定时器Timer功能???

解决方案 »

  1.   

    WaitForSingleObject,不过要看上层程序如何调用了。
      

  2.   


    以下代码就可以,timmer可以不要窗口的。VOID CALLBACK MyTimerProc(          HWND hwnd,
        UINT uMsg,
        UINT_PTR idEvent,
        DWORD dwTime
    )
    {};
    SetTimer(NULL,                // handle to main window 
        100,               // timer identifier 
        5000,                     // 5-second interval 
        (TIMERPROC) MyTimerProc); // timer callback
      

  3.   

    这是MSDN中的解释:UINT_PTR SetTimer(          HWND hWnd,
        UINT_PTR nIDEvent,
        UINT uElapse,
        TIMERPROC lpTimerFunc
    );
    hWnd参数解释
    [in] Handle to the window to be associated with the timer. This window must be owned by the calling thread. If this parameter is NULL, no window is associated with the timer and the nIDEvent parameter is ignored. 
      

  4.   

    就用API,SetTimer加回调。当然隐藏窗口也可以。
      

  5.   

    如果要跨进程定时器的话就用setwaitabletimer