Solved

Monitoring an external application

Posted on 2004-04-13
4
542 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

717 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