How to kill a process of a calling app

  • Thread starter Thread starter jake
  • Start date Start date
J

jake

Hello,

I have an application that calls another application. Depending on what
the user selects from application 2 I would like to kill application 1. How
can I accomplish this? Thanks in advance.

Jake
 
jake said:
I have an application that calls another application. Depending on what the
user selects from application 2 I would like to kill application 1. How can
I accomplish this?

If you want to be notified about user interaction in the other application
(for example, clicking buttons), you will have to utilize a Win32 hook,
typically implemented in a standard Win32 DLL implemented in VC++ or Delphi.

For starting and closing a process, take a look at this code:

\\\
Imports System.Diagnostics
..
..
..
Dim p As Process = Process.Start(...)
....
If...Then
p.CloseMainWindow()
End If
....
///
 
The creation of the process is not close application one like the user wanted

Yes, the user can launch the second application using your code, but you
don't go as far as closing the first one.

Obviously, a way of going about it is to pass the Handle of the first
application to the second & using DestroyWindow to kill it off.

Another way to go about it is to get the process name of application one
from application two & then killing application one from that. So, all you
have to do is to GetProcessByName etc.
 
Crouchie1998,

Do you have a sample on how to do this or a link to get me started? I
would appreciate it. Thanks.

Jake
 
Crouchie1998 said:
Obviously, a way of going about it is to pass the Handle of the first
application to the second & using DestroyWindow to kill it off.

MSDN:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top