| 21 | }; |
| 22 | |
| 23 | WindowTextValue WindowClassNameText(HWND hwnd) { |
| 24 | std::vector<wchar_t> buffer(256, L'\0'); |
| 25 | for (;;) { |
| 26 | const int copied = ::GetClassNameW(hwnd, buffer.data(), static_cast<int>(buffer.size())); |
| 27 | if (copied <= 0) |
| 28 | return WindowTextValue(); |
| 29 | if (static_cast<size_t>(copied) < buffer.size() - 1) |
| 30 | return WindowTextValue(std::wstring(buffer.data(), static_cast<size_t>(copied))); |
| 31 | buffer.assign(buffer.size() * 2, L'\0'); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | WindowTextValue WindowTitleText(HWND hwnd) { |
| 36 | const int length = ::GetWindowTextLengthW(hwnd); |
no test coverage detected