Debian Codegraph @

win32/plugins/peopsxgl/winsrc/ssave.c

raw
1 /***************************************************************************
2 ssave.c - description
3 -------------------
4 begin : Sun Mar 08 2009
5 copyright : (C) 1999-2009 by Pete Bernert
6 web : www.pbernert.com
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. See also the license.txt file for *
15 * additional informations. *
16 * *
17 ***************************************************************************/
18
19 //*************************************************************************//
20 // History of changes:
21 //
22 // 2009/03/08 - Pete
23 // - generic cleanup for the Peops release
24 //
25 //*************************************************************************//
26
27 #include "stdafx.h"
28
29 #include "externals.h"
30
31 ////////////////////////////////////////////////////////////////////////
32 // screensaver stuff: dynamically load kernel32.dll to avoid export dependeny
33 ////////////////////////////////////////////////////////////////////////
34
35 #ifdef __MINGW32__
36 #define EXECUTION_STATE DWORD
37 #endif
38
39 void EnableScreenSaver(BOOL bEnab)
40 {
41 HINSTANCE hKernel32 = NULL;
42 EXECUTION_STATE (WINAPI *D_SetThreadExecutionState)(EXECUTION_STATE esFlags);
43
44 if(bEnab)
45 {
46 hKernel32 = LoadLibrary("kernel32.dll");
47 if(hKernel32 != NULL)
48 {
49 if((D_SetThreadExecutionState=(EXECUTION_STATE (WINAPI *)(EXECUTION_STATE))GetProcAddress(hKernel32,"SetThreadExecutionState"))!=NULL)
50 D_SetThreadExecutionState(ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED);
51 FreeLibrary(hKernel32);
52 }
53 }
54 else
55 {
56 hKernel32 = LoadLibrary("kernel32.dll");
57 if(hKernel32 != NULL)
58 {
59 if((D_SetThreadExecutionState=(EXECUTION_STATE (WINAPI *)(EXECUTION_STATE))GetProcAddress(hKernel32,"SetThreadExecutionState"))!=NULL)
60 D_SetThreadExecutionState(ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED|ES_CONTINUOUS);
61 FreeLibrary(hKernel32);
62 }
63 }
64 }
65