| 81 | } |
| 82 | |
| 83 | void ConcreteService::ServiceMain() |
| 84 | { |
| 85 | mServiceStatusHandle = RegisterServiceCtrlHandlerEx( |
| 86 | mServiceName.c_str(), ServiceCtrlHandlerEx, this); |
| 87 | |
| 88 | // If unable to register the service control handle, have to |
| 89 | // bail |
| 90 | if (mServiceStatusHandle == nullptr) { |
| 91 | return; |
| 92 | } |
| 93 | |
| 94 | // Next setup to receive notfications to monitor if the display |
| 95 | // adapters on the system are changed so we can update the telemetry |
| 96 | // providers |
| 97 | DEV_BROADCAST_DEVICEINTERFACE NotificationFilter{}; |
| 98 | NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); |
| 99 | NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; |
| 100 | NotificationFilter.dbcc_classguid = GUID_DEVINTERFACE_DISPLAY_ADAPTER; |
| 101 | mDeviceNotifyHandle = RegisterDeviceNotification( |
| 102 | mServiceStatusHandle, &NotificationFilter, DEVICE_NOTIFY_SERVICE_HANDLE); |
| 103 | if (mDeviceNotifyHandle == nullptr) { |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | mServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; |
| 108 | mServiceStatus.dwServiceSpecificExitCode = 0; |
| 109 | |
| 110 | ReportServiceStatus(SERVICE_START_PENDING, NO_ERROR, 3000); |
| 111 | |
| 112 | |
| 113 | ServiceInit(); |
| 114 | |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | void ConcreteService::ServiceInit() |
| 119 | { |