Link to home
Start Free TrialLog in
Avatar of bsugden
bsugden

asked on

Closing Window Instances

Does any one know how to close all instances of a window, like Internet Exlporer or Netscape Navigator for example. I would prefer an example of C++ code. I know it has something to do with findWindow() or findWindowEx().
Can any one help?

Thanks
Avatar of bsugden
bsugden

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of alexo
alexo
Flag of Antarctica image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
An example:

        #define SUBSTRING "Notepad"

        #define STRICT
        #include <windows.h>

        BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);

        int main()
        {
            EnumWindows(EnumWindowsProc, NULL);
            return 0;
        }

        BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
        {
            char buffer[512];
            GetWindowText(hwnd, buffer, sizeof buffer);
            if (strstr(buffer, SUBSTRING))
                SendMessage(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
                // or: ShowWindow(hwnd, SW_MINIMIZE);
            return TRUE;
        }

Modify as needed.
And the autograder hits again!
Thank you so much for your consideration.