用户开了一个程序后,如果5分钟内什么都没干,我就关掉程序,但是如何确定他什么都没干的时间呢?

解决方案 »

  1.   

    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
      PSTR szCmdLine, int iCmdShow)
    {
    ......static int count = 0;
    while (TRUE)
    {
    if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))  //假如消息队列有消息
    {
    if (msg.message == WM_QUIT)
    break ;
    TranslateMessage (&msg) ;
    DispatchMessage (&msg) ;
                      count = 0;
    }
    else  //假如消息队列没有消息 表明程序现在正空闲,什么也没做
    {
    count++;
                      if (count >= 1000)
                          break;
    }
    }
    return 1;
    }
      

  2.   

    忘了一句
    MSG msg ;