Closing a Particular application from VB


How can i close a particular application from VB code.

I am running 4-5 applications and I want to hit a button which will close a particular application so that i do not need to go into that application and press exit/close.
That small vb form will work as a model form which will be on the top of  all the windows.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ITCDevloperAuthor Commented:
Hi Anil,

This code works only if I know the title of the application,
my application title always change when I open a form or record, the header/title shows the opened form  name and record name.


Craig WardmanSoftware Developer & Solution ArchitectCommented:
the best way to do this would be to make your program start the processes itself and record the process id, then use this to terminate the appropriate app..
Eduard GherguLeader SibiuCommented:

You can use EnumWindows for enumerate all top level windows and GetClassName in order to get for these windows the class names. If the class name is the same with the one that you'are expecting, you can call CloseWindow function in order to close the application.
Also, for some examples, you can have a look at :
or perform a search on

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.