Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <memory>
- #include <string>
- int main()
- {
- auto titleToFind = L"Developer tools";
- EnumWindows([](HWND hwnd, LPARAM lParam) {
- auto titleToFind = reinterpret_cast<LPTSTR>(lParam);
- int size = GetWindowTextLength(hwnd) + 1;
- auto buffer = std::make_unique<wchar_t []>(size);
- GetWindowText(hwnd, buffer.get(), size);
- auto title = std::wstring{ buffer.get() };
- if (IsWindowVisible(hwnd) && title.find(titleToFind) != std::wstring::npos) {
- SendMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0);
- }
- return TRUE;
- }, reinterpret_cast<LPARAM>(titleToFind));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement