终端一体化运控平台
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

31 wiersze
821 B

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace BPASmartClient.MorkT
  8. {
  9. public class PreventSleep
  10. {
  11. [DllImport("kernel32.dll")]
  12. static extern uint SetThreadExecutionState(uint dwThreadId);
  13. const uint ES_SYSTEM_REQUIRED = 0x00000001;
  14. const uint ES_DISPLAY_REQUIRED = 0x00000002;
  15. const uint ES_CONTINUOUS = 0x80000000;
  16. public static void SleepControl(bool isSleep)
  17. {
  18. if (isSleep)
  19. {
  20. SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED);
  21. }
  22. else
  23. {
  24. SetThreadExecutionState(ES_CONTINUOUS);
  25. }
  26. }
  27. }
  28. }