Changeset 377


Ignore:
Timestamp:
8/10/2008 9:22:15 AM (6 years ago)
Author:
lowjoel
Message:

Implemented #37

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EraserDll/Eraser.cpp

    r376 r377  
    20512051eraserThread(LPVOID param1) 
    20522052{ 
     2053    // prevent the computer from going to sleep, since users tend to leave the computer 
     2054    // on overnight to complete a task. 
     2055    typedef EXECUTION_STATE (*WINAPI pSetThreadExecutionState)(EXECUTION_STATE esFlags); 
     2056    static pSetThreadExecutionState SetThreadExecutionState = NULL; 
     2057    if (!SetThreadExecutionState) 
     2058    { 
     2059        HMODULE kernel32 = LoadLibrary("kernel32.dll"); 
     2060        SetThreadExecutionState = reinterpret_cast<pSetThreadExecutionState>( 
     2061            GetProcAddress(kernel32, "_SetThreadExecutionState")); 
     2062    } 
     2063    class PreventComputerSleep 
     2064    { 
     2065    public: 
     2066        PreventComputerSleep() 
     2067        { 
     2068            if (!SetThreadExecutionState) 
     2069                return; 
     2070            SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED); 
     2071        } 
     2072 
     2073        ~PreventComputerSleep() 
     2074        { 
     2075            if (!SetThreadExecutionState) 
     2076                return; 
     2077            SetThreadExecutionState(ES_CONTINUOUS); 
     2078        } 
     2079    } SleepDeny; 
     2080 
    20532081    AFX_MANAGE_STATE(AfxGetStaticModuleState()); 
    20542082    eraserTraceBase("eraserThread\n"); 
Note: See TracChangeset for help on using the changeset viewer.