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?

Delphi3
LVL 4
delphi3Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
intheConnect With a Mentor Commented:
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

var
  MyHandle: THandle;
begin
  MyHandle := FindWindow(nil, 'The_Window_Caption');
{or can do  MyHandle := FindWindow(The_Window_Classname, 'Nil'); }
  if MyHandle <> 0 then
  begin
    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);
  end;
end;

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".

0
 
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

Delphi3
0
 
intheCommented:
hi,
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.
0
All Courses

From novice to tech pro — start learning today.