c++定时器SetTimer

来源:互联网 发布:淘宝名字能改吗 编辑:程序博客网 时间:2024/05/21 00:20
#include<iostream>#include <windows.h>   using namespace std;void   CALLBACK   TimerProc(HWND   hWnd,UINT   nMsg,UINT   nTimerid,DWORD   dwTime); int main(){    int a = SetTimer(NULL,1,100,TimerProc);//第二个参数是id,第三个参数是100ms时间    MSG msg;    while(GetMessage(&msg,NULL,0,0))    {        if(msg.message==WM_TIMER)        {        DispatchMessage(&msg);        }    }    return 0;}void   CALLBACK   TimerProc(HWND   hWnd,UINT   nMsg,UINT   nTimerid,DWORD   dwTime){    cout<<"hello"<<endl;}