2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: services/spoolsv/spoolsv.c
5 * PURPOSE: Printer spooler
6 * PROGRAMMER: Eric Kohl
9 /* INCLUDES *****************************************************************/
13 #include <wine/debug.h>
15 WINE_DEFAULT_DEBUG_CHANNEL(spoolsv
);
18 /* GLOBALS ******************************************************************/
20 static VOID CALLBACK
ServiceMain(DWORD argc
, LPWSTR
*argv
);
21 static WCHAR ServiceName
[] = L
"Spooler";
22 static SERVICE_TABLE_ENTRYW ServiceTable
[] =
24 {ServiceName
, ServiceMain
},
28 SERVICE_STATUS_HANDLE ServiceStatusHandle
;
29 SERVICE_STATUS ServiceStatus
;
32 /* FUNCTIONS *****************************************************************/
35 UpdateServiceStatus(DWORD dwState
)
37 ServiceStatus
.dwServiceType
= SERVICE_WIN32_OWN_PROCESS
;
38 ServiceStatus
.dwCurrentState
= dwState
;
40 if (dwState
== SERVICE_RUNNING
)
41 ServiceStatus
.dwControlsAccepted
= SERVICE_ACCEPT_STOP
| SERVICE_ACCEPT_SHUTDOWN
;
43 ServiceStatus
.dwControlsAccepted
= 0;
45 ServiceStatus
.dwWin32ExitCode
= 0;
46 ServiceStatus
.dwServiceSpecificExitCode
= 0;
47 ServiceStatus
.dwCheckPoint
= 0;
49 if (dwState
== SERVICE_START_PENDING
||
50 dwState
== SERVICE_STOP_PENDING
)
51 ServiceStatus
.dwWaitHint
= 10000;
53 ServiceStatus
.dwWaitHint
= 0;
55 SetServiceStatus(ServiceStatusHandle
,
61 ServiceControlHandler(DWORD dwControl
,
66 TRACE("ServiceControlHandler() called\n");
70 case SERVICE_CONTROL_STOP
:
71 TRACE(" SERVICE_CONTROL_STOP received\n");
72 UpdateServiceStatus(SERVICE_STOPPED
);
75 case SERVICE_CONTROL_INTERROGATE
:
76 TRACE(" SERVICE_CONTROL_INTERROGATE received\n");
77 SetServiceStatus(ServiceStatusHandle
,
81 case SERVICE_CONTROL_SHUTDOWN
:
82 TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
83 UpdateServiceStatus(SERVICE_STOPPED
);
87 TRACE(" Control %lu received\n");
88 return ERROR_CALL_NOT_IMPLEMENTED
;
94 ServiceMain(DWORD argc
, LPWSTR
*argv
)
96 UNREFERENCED_PARAMETER(argc
);
97 UNREFERENCED_PARAMETER(argv
);
99 TRACE("ServiceMain() called\n");
101 ServiceStatusHandle
= RegisterServiceCtrlHandlerExW(ServiceName
,
102 ServiceControlHandler
,
105 TRACE("Calling SetServiceStatus()\n");
106 UpdateServiceStatus(SERVICE_RUNNING
);
107 TRACE("SetServiceStatus() called\n");
110 TRACE("ServiceMain() done\n");
115 wmain(int argc
, WCHAR
*argv
[])
117 UNREFERENCED_PARAMETER(argc
);
118 UNREFERENCED_PARAMETER(argv
);
120 TRACE("Spoolsv: main() started\n");
122 StartServiceCtrlDispatcher(ServiceTable
);
124 TRACE("Spoolsv: main() done\n");