Can I use a SetTimer() API in a console C++ application?

后端 未结 6 990
予麋鹿
予麋鹿 2020-12-09 22:08

I have a console application that is using a DLL file that uses a SetTimer() call to create a timer and fire a function within itself. The call is below:

<
6条回答
  •  感情败类
    2020-12-09 22:12

    Very simple timer without Windows

    MSG Msg;
    
    UINT TimerId = (UINT)SetTimer(NULL, 0, 0, NULL); // 0 minute
    
    while (TRUE)
    {
        GetMessage(&Msg, NULL, 0, 0);
    
        if (Msg.message == WM_TIMER)
        {
            KillTimer(NULL, TimerId);
    
            cout << "timer message\n";
    
            TimerId = (UINT)SetTimer(NULL, 0, 60000, NULL); // one minute.
        }
    
        DispatchMessage(&Msg);
    }
    

提交回复
热议问题