DLL entry
| 610 | |
| 611 | // DLL entry |
| 612 | bool APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpRes) { |
| 613 | switch (reason) |
| 614 | { |
| 615 | case DLL_PROCESS_ATTACH: { |
| 616 | // enable dark mode for the current process window |
| 617 | EnableDarkMode(nullptr); |
| 618 | |
| 619 | // catch windows that have been created before we set up the CBTProc hook |
| 620 | std::vector<HWND> windowHandles; |
| 621 | GetAllWindowsByProcessID(GetCurrentProcessId(), windowHandles); |
| 622 | |
| 623 | for (const HWND& hWnd : windowHandles) { |
| 624 | SetWindowSubclass(hWnd, CallWndSubClassProc, 0, 0); |
| 625 | EnableDarkMode(hWnd); |
| 626 | } |
| 627 | |
| 628 | // set up the CBTProc hook to catch new windows |
| 629 | g_hook = SetWindowsHookEx(WH_CBT, CBTProc, nullptr, GetCurrentThreadId()); |
| 630 | break; |
| 631 | } |
| 632 | case DLL_PROCESS_DETACH: { |
| 633 | if (g_hook) { |
| 634 | UnhookWindowsHookEx(g_hook); |
| 635 | g_hook = nullptr; |
| 636 | } |
| 637 | break; |
| 638 | } |
| 639 | default: break; |
| 640 | } |
| 641 | |
| 642 | return true; |
| 643 | } |
nothing calls this directly
no test coverage detected