另一种定时器

来源:互联网 发布:readfile java 编辑:程序博客网 时间:2024/05/21 10:50
#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 ;}

0 0