c++.windows.16-bits - Shutdown External App
- Mark Evans <mevans zyvex.com> Jul 23 2001
- Dan Rushe <thecourtjesture advnet.net> Jul 27 2001
- Mark Evans <mevans zyvex.com> Aug 08 2001
Given two Win16 applications running on Windows 98: One of the applications would like to close the other at shutdown time. The problem is that it doesn't have the task handle for the other app. Win16 seems to offer limited task management calls. Would this technique work even in theory: EnumWindows -- get all top-level windows in all running programs GetWindowTask on the one I need PostAppMessage (WM_QUIT) on the resulting task I think if I can get the window of the remote app (it has only one), then from there I can maneuver around. The problem is what facility exists in Win16 to get the handle to a remote app's main window. Open to ideas here, Mark
Jul 23 2001
That should work, but you shouldn't need to find the window's task handle. As you get passed each HWND in the system, you can pass it on to GetWindowText() to check the caption. If it's the window you are looking for, then call PostAppMessage(hWnd,WM_QUIT,0,0). This works if you know the window's caption (assuming it has one). If you know the window's class name, you could use GetClassName() instead checking the caption. Hope this helps, Dan Rushe thecourtjesture advnet.net Mark Evans wrote:Given two Win16 applications running on Windows 98: One of the applications would like to close the other at shutdown time. The problem is that it doesn't have the task handle for the other app. Win16 seems to offer limited task management calls. Would this technique work even in theory: EnumWindows -- get all top-level windows in all running programs GetWindowTask on the one I need PostAppMessage (WM_QUIT) on the resulting task I think if I can get the window of the remote app (it has only one), then from there I can maneuver around. The problem is what facility exists in Win16 to get the handle to a remote app's main window. Open to ideas here, Mark
Jul 27 2001
This was my solution: other_window = FindWindow(NULL,"Other Window Title"); if (other_window != 0) PostMessage(other_window,WM_DESTROY,0,0); Since I know the title of the external window these two lines of code always work. Mark On Sat, 28 Jul 2001 00:38:08 -0400, Dan Rushe <thecourtjesture advnet.net> wrote:That should work, but you shouldn't need to find the window's task handle. As you get passed each HWND in the system, you can pass it on to GetWindowText() to check the caption. If it's the window you are looking for, then call PostAppMessage(hWnd,WM_QUIT,0,0). This works if you know the window's caption (assuming it has one). If you know the window's class name, you could
GetClassName() instead checking the caption. Hope this helps, Dan Rushe thecourtjesture advnet.net Mark Evans wrote:Given two Win16 applications running on Windows 98: One of the applications would like to close the other at shutdown time. The problem is that it doesn't have the task handle for the other app. Win16 seems to offer limited task management calls. Would this technique work even in theory: EnumWindows -- get all top-level windows in all running programs GetWindowTask on the one I need PostAppMessage (WM_QUIT) on the resulting task I think if I can get the window of the remote app (it has only one), then from there I can maneuver around. The problem is what facility exists in Win16 to get the handle to a remote app's main window. Open to ideas here, Mark
Aug 08 2001