Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing an Application in VB

Status
Not open for further replies.

RSH

Technical User
Jun 15, 2000
55
0
0
US
The following code works very nicely to activate an application but now how does one get rid of it. Alt F4 works only from the keys not from code.


Private Sub Command1_Click()
RetVal = Shell("C:\Program Files\HomeConnect\VidCap.exe", 1)
End Sub
Thanks RSH
 
Hi,

You can send a 'close request' to the program using
-----------------------------------------------------------
Const NILL = 0&
Const WM_SYSCOMMAND = &H112
Const SC_CLOSE = &HF060&
Handle = SendMessage(Handle, WM_SYSCOMMAND, SC_CLOSE, NILL)
-----------------------------------------------------------

That should work with a windows program (if it is responding), however if you run a command line program you can't close it before its finished (shorth of killing the process). Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Thanks for the input. Ill give it a try.
73 RSH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top