这个也不难,但首先要保证你的定时器要在一个线程中设置,如果你用MFC,那么在控制台中你可以从CWinThread派生一个类,然后在这个类中设置定时器,但不像CWnd类中的定时器那么好用,看看::SetTimer的SDK方法的帮助,就是那么用的。

解决方案 »

  1.   

    嘿嘿~~~~~
    你画的坦克~呵呵
    Console可以使用waitabletimer啊,精度可调,但是95不能用:(。
    另外还可以使用WaitForSingleObject(xxx,time);//xxx是一个永远不会发生的事件
      

  2.   

    UINT SetTimer(
      HWND hWnd,              // handle of window for timer messages
      UINT nIDEvent,          // timer identifier
      UINT uElapse,           // time-out value
      TIMERPROC lpTimerFunc   // address of timer procedure
    );
      

  3.   

    SetTimer(...)函数中有一个参数为函数指针,作为timer的回调函数。
    在这个函数中处理你的操作
      

  4.   

    或者用多媒体定时器中断,winmm.lib
    它的精度比vc中的settimer()要高得多
      

  5.   

    恕本人愚钝
    BOOL SetWaitableTimer(
      HANDLE hTimer,                          // handle to timer
      const LARGE_INTEGER *pDueTime,          // timer due time
      LONG lPeriod,                           // timer interval
      PTIMERAPCROUTINE pfnCompletionRoutine,  // completion routine
      LPVOID lpArgToCompletionRoutine,        // completion routine parameter
      BOOL fResume                            // resume state
    );
    其中pfnCompletionRoutine,lpArgToCompletionRoutine不知如何设置,还望各位赐教。
      

  6.   

    http://www.csdn.net/expert/topic/464/464120.shtm帮帮我吧(网吧管理软件)
      

  7.   

    各位,我现在是这样的情况:
    iRet = SetTimer(NULL,1,1000,ShowText2);
    其中ShowText2如下:
    VOID CALLBACK ShowText2(HWND hwnd, UINT uMsg,  UINT idEvent, DWORD dwTime)
    {
    cout<<"timer is runing"<<endl;
    }
    然后程序员行到SetTimer后,iRet得到了一个非0返回值,应该算是成功了吧。
    但是接下来就没有反应了,我怀疑是不是主程序_tmain到头了所以不执行Timer指定的函数,于是用Sleep和scanf等试验等待,感觉这些东西都将进程堵死了,估计开辟另一个线程就可以了吧。