How to check in C++ if the system is active?

前端 未结 6 1707
温柔的废话
温柔的废话 2021-02-09 10:16

I\'m writing code that need to run only when there is no human activity on the PC, like when the screensaver is running. Any suggestions on how to do this in c++ under windows?<

6条回答
  •  深忆病人
    2021-02-09 10:47

    Use SystemParametersInfo(...)

       private const int SPI_GETSCREENSAVERACTIVE = 16;
       SystemParametersInfo( SPI_GETSCREENSAVERACTIVE, 0, 
             ref isActive, 0 );
          return isActive;
    

    Reference: http://www.codeproject.com/KB/cs/ScreenSaverControl.aspx

提交回复
热议问题