100分请问:在DLL中,没有窗体,而且不用线程,能否实现定时器Timer功能???
在DLL中,没有窗体,而且不用线程,能否实现定时器Timer功能???
[解决办法]
WaitForSingleObject,不过要看上层程序如何调用了。
[解决办法]
以下代码就可以,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
[解决办法]
这是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.
[解决办法]
弄个隐藏的窗口不好么。
[解决办法]
就用API,SetTimer加回调。当然隐藏窗口也可以。