| 187 | } |
| 188 | |
| 189 | void TaskViewVisibilityMonitor::Install() noexcept |
| 190 | { |
| 191 | if (!s_TaskViewVisibilityChangeMessage) |
| 192 | { |
| 193 | s_TaskViewVisibilityChangeMessage = RegisterWindowMessage(WM_TTBHOOKTASKVIEWVISIBILITYCHANGE.c_str()); |
| 194 | FAIL_FAST_LAST_ERROR_IF(!s_TaskViewVisibilityChangeMessage); |
| 195 | } |
| 196 | |
| 197 | if (!s_IsTaskViewOpenedMessage) |
| 198 | { |
| 199 | s_IsTaskViewOpenedMessage = RegisterWindowMessage(WM_TTBHOOKISTASKVIEWOPENED.c_str()); |
| 200 | FAIL_FAST_LAST_ERROR_IF(!s_IsTaskViewOpenedMessage); |
| 201 | } |
| 202 | |
| 203 | if (!s_WindowClassAtom) |
| 204 | { |
| 205 | const WNDCLASSEX wndClass = { |
| 206 | .cbSize = sizeof(wndClass), |
| 207 | .lpfnWndProc = WindowProc, |
| 208 | .hInstance = wil::GetModuleInstanceHandle(), |
| 209 | .lpszClassName = TTBHOOK_TASKVIEWMONITOR.c_str() |
| 210 | }; |
| 211 | |
| 212 | s_WindowClassAtom.reset(RegisterClassEx(&wndClass)); |
| 213 | FAIL_FAST_LAST_ERROR_IF_NULL(s_WindowClassAtom); |
| 214 | } |
| 215 | |
| 216 | if (!s_ThreadCleanupEvent) |
| 217 | { |
| 218 | s_ThreadCleanupEvent.reset(CreateEvent(nullptr, true, false, nullptr)); |
| 219 | FAIL_FAST_LAST_ERROR_IF_NULL(s_WindowClassAtom); |
| 220 | } |
| 221 | |
| 222 | if (!s_hThread) |
| 223 | { |
| 224 | s_hThread.reset(CreateThread(nullptr, 0, ThreadProc, wil::GetModuleInstanceHandle(), 0, nullptr)); |
| 225 | FAIL_FAST_LAST_ERROR_IF_NULL(s_hThread); |
| 226 | |
| 227 | #ifdef _DEBUG |
| 228 | FAIL_FAST_IF_FAILED(SetThreadDescription(s_hThread.get(), APP_NAME L" Task View Visibility Monitor Thread")); |
| 229 | #endif |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | void TaskViewVisibilityMonitor::Uninstall() noexcept |
| 234 | { |