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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to shut down another instance of an application

Status
Not open for further replies.

spence74

Programmer
Jul 16, 2004
34
0
0
US
I can detect another instance of an application running by using App.PrevInstance, is there a way to force that other instance of the application to shut down?
 

Why?

If you want just one instance of your app running, App.PrevInstance is a perfect solution - don't give user another instance.

Why do you want to start another and stop previous?

---- Andy
 
No time to post an example right now but, I believe you can use the PostMessage API, passing WM_CLOSE (&H10) for the wMsg parameter. Use EnumWindows along with a callback function that uses GetWindowTextLength and GetWindowText to identify and acquire a handle for the appropriate window.

There may be a better (safer) way to identify the correct window but I don't know what it is.

 
We've covered this in the past. Try doing a keyword search in this forum. If you can't find anything just shout and I'm sure we'll be able to help out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top