Solved

Monitoring an external application

Posted on 2004-04-13
4
537 Views
Last Modified: 2010-04-05
I'd like to write application which would launch some external program and notify me when the program will be closed. I also need possibility to force closing this program. Could anyone help me, please?
0
Comment
Question by:ZhaawZ
  • 3
4 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 125 total points
ID: 10817777
To launch program

procedure TForm1.Button1Click(Sender: TObject);
var
  cmd: string;
  procinf: TProcessInformation;
  stinfo: TStartUpInfo;
  exitcode: dword;
begin
    GetStartupInfo(stinfo);
    stinfo.wShowWindow := SW_HIDE;  //SW_SHOW
    cmd := 'some.exe';
    if CreateProcess(nil,PChar(cmd),nil,nil, False,0,  nil,nil,stinfo,procinf) then
      begin
      repeat
        Apprunning := WaitForSingleObject(procinf.hProcess,100) ;
        Application.ProcessMessages;
      until (Apprunning <> WAIT_TIMEOUT) ;
    end;
end;
0
 
LVL 17

Expert Comment

by:mokule
ID: 10817811
To terminate process

TerminateProcess(procinf.hProcess,0);
0
 
LVL 17

Expert Comment

by:mokule
ID: 10817979
One important information. To have possibility to terminate process You must have PROCESS_TERMINATE access right set in Security structure
0
 
LVL 11

Author Comment

by:ZhaawZ
ID: 10821048
tx for the answers ;)
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question