-
-/* Prevent Windows entering sleep/hibernation-mode while Wget is doing
- a lengthy transfer. Windows does not, by default, consider network
- activity in console-programs as activity! Works on Win-98/ME/2K
- and up. */
-static DWORD
-set_sleep_mode (DWORD mode)
-{
- HMODULE mod = LoadLibrary ("kernel32.dll");
- DWORD (WINAPI *_SetThreadExecutionState) (DWORD) = NULL;
- DWORD rc = (DWORD)-1;
-
- if (mod)
- (void *)_SetThreadExecutionState
- = GetProcAddress ((HINSTANCE)mod, "SetThreadExecutionState");
-
- if (_SetThreadExecutionState)
- {
- if (mode == 0) /* first time */
- mode = (ES_SYSTEM_REQUIRED | ES_CONTINUOUS);
- rc = (*_SetThreadExecutionState) (mode);
- }
- if (mod)
- FreeLibrary (mod);
- DEBUGP (("set_sleep_mode(): mode 0x%08lX, rc 0x%08lX\n", mode, rc));
- return rc;
-}