Stopping several running programs with a program.

I have Win98 and D4. If  there are several programs (3) running at one time and I want to close or Application.Terminate  all (3) with the aid of another  program then what procedure would I use in that closing program? Can you specify the details with a model or an example?

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.

are these your delphi programs yu want to close or others?
do you know th window captions or the clasnames?

well not too pretty but can do

  MyHandle: THandle;
  MyHandle := FindWindow(nil, 'The_Window_Caption');
{or can do  MyHandle := FindWindow(The_Window_Classname, 'Nil'); }
  if MyHandle <> 0 then
    PostMessage(MyHandle, WM_QUIT, 0, 0);
    //or if you want to give the window a chance to confirm the close do this
    //PostMessage(MyHandle, WM_CLOSE, 0, 0);

do a test on notepad etc..

btw notepad classname is "notepad"
whereas most other programs have some weird name for a class name which you can get using "sinfo" or  "winsight32".


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
delphi3Author Commented:
Hi inthe,
I have tried your example and it is very caption specific. I was thinking about MS Outlook Express but if that form is not on the screen it will not work. Still I understand now.

Thanks for the example.

The points are yours.  If they do not show up on your count please let me know how to proceed so that you get them

remember you can do:
MyHandle := FindWindow(The_Window_Classname, 'Nil');

if you need classnames of outlook express i can find them easyily using "sinfo".
i could mail a copy of sinfo if you want or do a search yahoo for a download address ,it comes in very handy sometimes for these type of things.
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.