另一種定時器

#include "stdafx.h"

#define _WIN32_WINNT 0x0500
#include <iostream>
#include <stdlib.h>
#include <windows.h>
using namespace std;

static void CALLBACK BroadCast(LPVOID lpParam, BOOLEAN  bTimerOrWaitFired)// 注意第二個參數必須爲BOOLEAN類型
{
     int *pInt = (int*)lpParam;
    cout<<*pInt<<endl;
    *pInt =*pInt+1;
}

void main()
{
    int nA = 0; 
    HANDLE hBstTimerQueue;
    HANDLE m_hBstTimeQueue = CreateTimerQueue();
    CreateTimerQueueTimer(&hBstTimerQueue, m_hBstTimeQueue, BroadCast, &nA, 0, 1000, 0);

    while(1) { 
        if(nA > 50) 
            break;
    }
    DeleteTimerQueue(hBstTimerQueue);

    system("PAUSE");
    return ;

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章