Exemplo n.º 1
0
int _tmain(int argc, _TCHAR **argv)
{
    HANDLE hTimerQueue = CreateTimerQueue();
    HANDLE hTimer = NULL;

    DWORD dwDueTimeInMs = 5000;
    DWORD dwPeriod = 1000;

    if (NULL == hTimerQueue)
    {
        _tperror(_T("Failed to create timer queue."));
        return GetLastError();
    }

    if (!CreateTimerQueueTimer(&hTimer, hTimerQueue,
        TimerRoutine, (PVOID)GetTickCount(), dwDueTimeInMs, dwPeriod,
        WT_EXECUTEDEFAULT))
    {
        _tperror(_T("Failed to create timer."));
        return GetLastError();
    }

    _tprintf(_T("Call timer routine in %lu seconds...\n"),
        (unsigned long)dwDueTimeInMs / 1000);

    _tprintf(_T("Hit any key to delete the timer queue and cancel all queued timers!\n"));

    while (!_kbhit()) {
    }
    _getch();

    if (!DeleteTimerQueueEx(hTimerQueue, INVALID_HANDLE_VALUE))
    {
        _tprintf(_T("Failed to delete timer queue.\n"));
        return GetLastError();
    }

    _tprintf(_T("Now I think it is time to say goodbye.\n"));

    return 0;
}
Exemplo n.º 2
0
void StringSearcher::scan(const String &name) {
  if (m_verbose) {
    _ftprintf(stderr, _T("Scanning %-50s             \r"), name.cstr());
  }
  LexFileStream input(name);
  if(!input.ok()) {
    _tperror(name.cstr());
    return;
  }
  FindStringsLex lex;
  lex.newStream(&input);
//  lex.setDebug(true);
  bool lastWasDirective = false;
  InputToken sym;
  while (sym = (InputToken)lex.getNextLexeme()) {
    switch (sym) {
    case DIRECTIVE :
      lastWasDirective = true;
      break;
    case OLDSTRING :
      if(!lastWasDirective) {
        String         tmp = lex.getText();
        SourcePosition pos = lex.getStartPos(); pos.incrColumn();
        _tprintf(_T("%s%s: %s\n"), name.cstr(), pos.toString().cstr(), tmp.trim().cstr());
      }
      lastWasDirective = false;
      break;
    case OLDCHAR   :
      if(m_showOldStrings) {
        if(m_showOldChars) {
          if(!lastWasDirective) {
            String tmp = lex.getText();
            _tprintf(_T("%s%s: %s\n"), name.cstr(), lex.getPos().toString().cstr(), tmp.trim().cstr());
          }
        }
      }
      lastWasDirective = false;
      break;
    case NEWSTRING :
    case NEWCHAR   :
      lastWasDirective = false;
      break;
    case OTHER     :
      lastWasDirective = false;
      break;
    default:
      lastWasDirective = false;
      _ftprintf(stderr,_T("Unexpected symbol:%d\n"), sym);
    }
  }
}