Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.4 KiB

  1. #include "shsrvice.h"
  2. #include "mischlpr.h"
  3. #include "dbg.h"
  4. #include "tfids.h"
  5. //static
  6. HRESULT CGenericServiceManager::_RegisterServiceCtrlHandler(
  7. LPCWSTR pszServiceName, SERVICEENTRY* pse)
  8. {
  9. ASSERT(pse);
  10. HRESULT hres = E_FAIL;
  11. TRACE(TF_SERVICE, TEXT("Entered _RegisterServiceCtrlHandler"));
  12. pse->_ssh = RegisterServiceCtrlHandlerExW(pszServiceName,
  13. _ServiceHandler, pse);
  14. if (pse->_ssh)
  15. {
  16. #ifdef DEBUG
  17. lstrcpy(pse->_szServiceName, pszServiceName);
  18. #endif
  19. hres = S_OK;
  20. }
  21. else
  22. {
  23. // convert GetLastError to some HRESULT
  24. }
  25. return hres;
  26. }
  27. // static
  28. HRESULT CGenericServiceManager::StartServiceCtrlDispatcher()
  29. {
  30. HRESULT hres = E_FAIL;
  31. TRACE(TF_SERVICE, TEXT("Entered StartServiceCtrlDispatcher"));
  32. if (::StartServiceCtrlDispatcher(_rgste))
  33. {
  34. hres = S_OK;
  35. }
  36. return hres;
  37. }
  38. BOOL CGenericServiceManager::_SetServiceStatus(SERVICEENTRY* pse)
  39. {
  40. #ifdef DEBUG
  41. WCHAR sz[256];
  42. lstrcpy(sz, pse->_szServiceName);
  43. switch (pse->_servicestatus.dwCurrentState)
  44. {
  45. case SERVICE_STOPPED:
  46. lstrcat(sz, TEXT(": SERVICE_STOPPED"));
  47. break;
  48. case SERVICE_START_PENDING:
  49. lstrcat(sz, TEXT(": SERVICE_START_PENDING"));
  50. break;
  51. case SERVICE_STOP_PENDING:
  52. lstrcat(sz, TEXT(": SERVICE_STOP_PENDING"));
  53. break;
  54. case SERVICE_RUNNING:
  55. lstrcat(sz, TEXT(": SERVICE_RUNNING"));
  56. break;
  57. case SERVICE_CONTINUE_PENDING:
  58. lstrcat(sz, TEXT(": SERVICE_CONTINUE_PENDING"));
  59. break;
  60. case SERVICE_PAUSE_PENDING:
  61. lstrcat(sz, TEXT(": SERVICE_PAUSE_PENDING"));
  62. break;
  63. case SERVICE_PAUSED:
  64. lstrcat(sz, TEXT(": SERVICE_PAUSED"));
  65. break;
  66. default:
  67. lstrcat(sz, TEXT(": Unknown state"));
  68. break;
  69. }
  70. TRACE(TF_SERVICE, sz);
  71. #endif
  72. BOOL b = SetServiceStatus(pse->_ssh, &(pse->_servicestatus));
  73. #ifdef DEBUG
  74. if (!b)
  75. {
  76. TRACE(TF_SERVICE, TEXT("SetServiceStatus FAILED: GLE = 0x%08X"), GetLastError());
  77. }
  78. #endif
  79. return b;
  80. }
  81. // static
  82. HRESULT CGenericServiceManager::_HandleWantsDeviceEvents(
  83. LPCWSTR UNREF_PARAM(pszServiceName), BOOL fWantsDeviceEvents)
  84. {
  85. if (fWantsDeviceEvents)
  86. {
  87. TRACE(TF_SERVICE, TEXT("Wants Device Events"));
  88. }
  89. return S_OK;
  90. }