c++ 控制台定时器SetTimer

 class A
{
public:
void static CALLBACK TimeProc(
HWND hwnd,
UINT message,
UINT idTimer,
DWORD dwTime);
};

int main()
{
SetTimer(NULL,1,1000,A::TimeProc);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
if(msg.message==WM_TIMER)
{
DispatchMessage(&msg);
}

}
return 0;
}

void CALLBACK A::TimeProc(
HWND hwnd,
UINT message,
UINT idTimer,
DWORD dwTime)
{
cout<<"触发定时器!"<<endl;
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注