ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

thmsvc.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:        See COPYING in the top level directory
00003  * PROJECT:          ReactOS kernel
00004  * FILE:             services/thmsvc/thmsvc.c
00005  * PURPOSE:          Themes service
00006  * PROGRAMMER:       Giannis Adamopoulos
00007  */
00008 
00009 /* INCLUDES *****************************************************************/
00010 
00011 #define WIN32_NO_STATUS
00012 #include <windows.h>
00013 #include <uxundoc.h>
00014 
00015 #include "wine/debug.h"
00016 WINE_DEFAULT_DEBUG_CHANNEL(thmsvc);
00017 
00018 
00019 /* GLOBALS ******************************************************************/
00020 
00021 static VOID CALLBACK ServiceMain(DWORD argc, LPWSTR *argv);
00022 static WCHAR ServiceName[] = L"Themes";
00023 static SERVICE_TABLE_ENTRYW ServiceTable[] =
00024 {
00025     {ServiceName, ServiceMain},
00026     {NULL, NULL}
00027 };
00028 
00029 SERVICE_STATUS_HANDLE ServiceStatusHandle;
00030 SERVICE_STATUS ServiceStatus;
00031 
00032 
00033 /* FUNCTIONS *****************************************************************/
00034 
00035 static VOID
00036 UpdateServiceStatus(DWORD dwState)
00037 {
00038     ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
00039     ServiceStatus.dwCurrentState = dwState;
00040 
00041     if (dwState == SERVICE_RUNNING)
00042         ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
00043     else if (dwState == SERVICE_PAUSED)
00044         ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE;
00045     else
00046         ServiceStatus.dwControlsAccepted = 0;
00047 
00048     ServiceStatus.dwWin32ExitCode = 0;
00049     ServiceStatus.dwServiceSpecificExitCode = 0;
00050     ServiceStatus.dwCheckPoint = 0;
00051 
00052     if (dwState == SERVICE_START_PENDING ||
00053         dwState == SERVICE_STOP_PENDING ||
00054         dwState == SERVICE_PAUSE_PENDING ||
00055         dwState == SERVICE_CONTINUE_PENDING)
00056         ServiceStatus.dwWaitHint = 10000;
00057     else
00058         ServiceStatus.dwWaitHint = 0;
00059 
00060     SetServiceStatus(ServiceStatusHandle,
00061                      &ServiceStatus);
00062 }
00063 
00064 
00065 static DWORD WINAPI
00066 ServiceControlHandler(DWORD dwControl,
00067                       DWORD dwEventType,
00068                       LPVOID lpEventData,
00069                       LPVOID lpContext)
00070 {
00071     TRACE("ServiceControlHandler() called\n");
00072 
00073     switch (dwControl)
00074     {
00075         case SERVICE_CONTROL_STOP:
00076             TRACE("  SERVICE_CONTROL_STOP received\n");
00077             UpdateServiceStatus(SERVICE_STOPPED);
00078             ThemeHooksRemove();
00079             return ERROR_SUCCESS;
00080 
00081         case SERVICE_CONTROL_PAUSE:
00082             TRACE("  SERVICE_CONTROL_PAUSE received\n");
00083             UpdateServiceStatus(SERVICE_PAUSED);
00084             return ERROR_SUCCESS;
00085 
00086         case SERVICE_CONTROL_CONTINUE:
00087             TRACE("  SERVICE_CONTROL_CONTINUE received\n");
00088             UpdateServiceStatus(SERVICE_RUNNING);
00089             return ERROR_SUCCESS;
00090 
00091         case SERVICE_CONTROL_INTERROGATE:
00092             TRACE("  SERVICE_CONTROL_INTERROGATE received\n");
00093             SetServiceStatus(ServiceStatusHandle,
00094                              &ServiceStatus);
00095             return ERROR_SUCCESS;
00096 
00097         case SERVICE_CONTROL_SHUTDOWN:
00098             TRACE("  SERVICE_CONTROL_SHUTDOWN received\n");
00099             UpdateServiceStatus(SERVICE_STOPPED);
00100             return ERROR_SUCCESS;
00101 
00102         default :
00103             TRACE("  Control %lu received\n");
00104             return ERROR_CALL_NOT_IMPLEMENTED;
00105     }
00106 }
00107 
00108 
00109 static VOID CALLBACK
00110 ServiceMain(DWORD argc, LPWSTR *argv)
00111 {
00112     UNREFERENCED_PARAMETER(argc);
00113     UNREFERENCED_PARAMETER(argv);
00114 
00115     TRACE("ServiceMain() called\n");
00116 
00117     ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
00118                                                         ServiceControlHandler,
00119                                                         NULL);
00120 
00121     TRACE("Calling SetServiceStatus()\n");
00122     UpdateServiceStatus(SERVICE_RUNNING);
00123     TRACE("SetServiceStatus() called\n");
00124 
00125     ThemeHooksInstall();
00126 
00127     TRACE("ServiceMain() done\n");
00128 }
00129 
00130 
00131 int
00132 wmain(int argc, WCHAR *argv[])
00133 {
00134     UNREFERENCED_PARAMETER(argc);
00135     UNREFERENCED_PARAMETER(argv);
00136 
00137     TRACE("thmsvc: main() started\n");
00138 
00139     StartServiceCtrlDispatcher(ServiceTable);
00140 
00141     TRACE("thmsvc: main() done\n");
00142 
00143     return 0;
00144 }
00145 
00146 /* EOF */

Generated on Sun May 27 2012 04:17:55 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.