1. 程式人生 > >c++定時器SetTimer

c++定時器SetTimer

#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; }