2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: base/services/shsvcs/thmsvc.c
5 * PURPOSE: Themes service
6 * PROGRAMMER: Giannis Adamopoulos
9 /* INCLUDES *****************************************************************/
12 #include <wine/debug.h>
14 WINE_DEFAULT_DEBUG_CHANNEL(shsvcs
);
16 /* GLOBALS ******************************************************************/
18 static WCHAR ServiceName
[] = L
"Themes";
20 SERVICE_STATUS_HANDLE ServiceStatusHandle
;
21 SERVICE_STATUS ServiceStatus
;
24 /* FUNCTIONS *****************************************************************/
26 HANDLE StartEvent
, StopEvent
;
29 UpdateServiceStatus(DWORD dwState
)
31 ServiceStatus
.dwServiceType
= SERVICE_WIN32_OWN_PROCESS
;
32 ServiceStatus
.dwCurrentState
= dwState
;
34 if (dwState
== SERVICE_RUNNING
)
35 ServiceStatus
.dwControlsAccepted
= SERVICE_ACCEPT_PAUSE_CONTINUE
| SERVICE_ACCEPT_STOP
| SERVICE_ACCEPT_SHUTDOWN
;
36 else if (dwState
== SERVICE_PAUSED
)
37 ServiceStatus
.dwControlsAccepted
= SERVICE_ACCEPT_PAUSE_CONTINUE
;
39 ServiceStatus
.dwControlsAccepted
= 0;
41 ServiceStatus
.dwWin32ExitCode
= 0;
42 ServiceStatus
.dwServiceSpecificExitCode
= 0;
43 ServiceStatus
.dwCheckPoint
= 0;
45 if (dwState
== SERVICE_START_PENDING
||
46 dwState
== SERVICE_STOP_PENDING
||
47 dwState
== SERVICE_PAUSE_PENDING
||
48 dwState
== SERVICE_CONTINUE_PENDING
)
49 ServiceStatus
.dwWaitHint
= 10000;
51 ServiceStatus
.dwWaitHint
= 0;
53 SetServiceStatus(ServiceStatusHandle
,
59 ServiceControlHandler(DWORD dwControl
,
64 TRACE("ServiceControlHandler() called\n");
68 case SERVICE_CONTROL_STOP
:
69 TRACE(" SERVICE_CONTROL_STOP received\n");
71 /* Signal the theme server in winlogon to remove theme hooks */
72 ResetEvent(StartEvent
);
74 UpdateServiceStatus(SERVICE_STOPPED
);
77 case SERVICE_CONTROL_PAUSE
:
78 TRACE(" SERVICE_CONTROL_PAUSE received\n");
79 UpdateServiceStatus(SERVICE_PAUSED
);
82 case SERVICE_CONTROL_CONTINUE
:
83 TRACE(" SERVICE_CONTROL_CONTINUE received\n");
84 UpdateServiceStatus(SERVICE_RUNNING
);
87 case SERVICE_CONTROL_INTERROGATE
:
88 TRACE(" SERVICE_CONTROL_INTERROGATE received\n");
89 SetServiceStatus(ServiceStatusHandle
,
93 case SERVICE_CONTROL_SHUTDOWN
:
94 TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
95 UpdateServiceStatus(SERVICE_STOPPED
);
99 TRACE(" Control %lu received\n");
100 return ERROR_CALL_NOT_IMPLEMENTED
;
106 ThemeServiceMain(DWORD argc
, LPTSTR
*argv
)
108 UNREFERENCED_PARAMETER(argc
);
109 UNREFERENCED_PARAMETER(argv
);
111 ServiceStatusHandle
= RegisterServiceCtrlHandlerExW(ServiceName
,
112 ServiceControlHandler
,
114 if (!ServiceStatusHandle
)
116 ERR("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
120 StartEvent
= CreateEventW(NULL
, TRUE
, FALSE
, L
"Global\\ThemeStartEvent");
121 StopEvent
= CreateEventW(NULL
, TRUE
, FALSE
, L
"Global\\ThemeStopEvent");
123 UpdateServiceStatus(SERVICE_RUNNING
);
125 /* Signal the theme server in winlogon to install theme hooks */
126 ResetEvent(StopEvent
);
127 SetEvent(StartEvent
);