CompuServe Thread

#A NEW Shell Problem

7 messages in this thread
#1795From: Selden McCabeOct 7, 1991 11:35 AM
Costas, This is a summary of what I've tried to do to terminate a shelled windows application: Here I start the program and get the window handle: x% = Shell(commandline$, 3) ShellWindowHWnd% = GetActiveWindow%() Here the user chooses Quit, and I try to kill the shelled program if it is still running: '—try three different methods to kill the window If IsWindow%(ShellWindowHWnd%) <> 0 Then x% = DestroyWindow(ShellWindowHWnd%) End If If IsWindow%(ShellWindowHWnd%) <> 0 Then x% = SendMessage(ShellWindowHWnd%, WM_SYSCOMMAND, SC_CLOSE, b) End If If IsWindow%(ShellWindowHWnd%) <> 0 Then n% = PostMessage(ShellWindowWHnd%, WM_SYSCOMMAND, SC_RESTORE, 0) x% = SetfocusAPI(ShellWindowHWnd%) SendKeys "%{F4}", TRUE End If The SendMessage with WM_SYSCOMMAND SC_CLOSE seems to actually close some programs, but causes others to hang the system. As far as I can tell, the other methods ether do nothing, or simply iconize the running program. Any further thoughts on this? best regards, Selden There are 3 Replies.
#1848From: Costas KitsosOct 7, 1991 2:10 PM
Selden, I've had the best luck with: WinClose& = SendMessage(ShellWindowHWnd%, WM_DESTROY, 0, ByVal 0&) Costas There is 1 Reply.
#1857From: Selden McCabeOct 7, 1991 3:46 PM
Thanks for the tip. How does one find these windows API functions in all the mounds of documentation? <grin> There are 2 Replies.
#1896From: Costas KitsosOct 7, 1991 7:44 PM
Search for Destroy, Quit, Close, Invalidate… <g>. BTW, I don't think any single method is the best. WM_DESTROY assumes that there is a WM_DESTROY message handling in th App. SC_CLOSE assumes that there is a system box or that Close is active, etc. Costas
#2044From: Costas KitsosOct 8, 1991 1:50 PM
Hi Selden, I found a new one that seems to work more often: AppClose& = SendMessage(ShellWindowHWnd%, WM_CLOSE, 0, ByVal 0&) Costas
#1906From: Don FunkOct 7, 1991 8:17 PM
Hi Selden, I have used the SendMessage with SC_CLOSE and have had no problems *if* the program I want to close *has* a 'CLOSE' option. Don Funk
#2049From: Don FunkOct 8, 1991 2:23 PM
Hi Selden, I have used the SendMessage with SC_CLOSE and have had no problems *if* the program I want to close *has* a 'CLOSE' option. Don Funk