🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #16412

Re: Kill a process

#16412
From: Vladimir Afanasyev
Date: Thu, 15 May 2003 14:34
36 lines
2087 bytes
Hi,

"Juan Diego Garc�s" <jgarces@amics.ch> wrote:
>I have two three application. The first one launches a process (with the
>CreateProcess API) called X, and from the second I have to stop this
>process.
>
>I found the TerminateProcess API, but the first parameter is the andle to
>the process. Is there an API to get this handle?
>
>Thanks
>
>Juan Diego Garc�s
>
>

To use TerminateProcess you need to use OpenProcess before.
The result of OpenProcess it is handle that you need.
To use OpenProcess you need to know ProcessId.

First process know ProcessId because it uses CreateProcess 
function (result - PROCESS_INFORMATION structure).

So the task of first process pass ProcessId to second 
process via file, pipe, etc.

The only problem that "TerminateProcess function is 
used to unconditionally cause a process to exit".
TerminateProcess do not it work clear - some dlls 
can be stay yet in memory after process termination.

Some additional problems can be for Win NT/2000/XP 
(access rights).

Vladimir.
Technical Details
Message-ID: <3ec3a581$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!pln-e!extra.newsguy.com!lotsanews.com!panix!dca1-feed2.news.algx.net!dfw3-feed1.news.algx.net!allegiance!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3ec399e6@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10cc67,877e15afb2c6135d
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-15 07:56:28 PST
From: "Vladimir Afanasyev" <avv@systema.kiev.ua>
Sender: "Vladimir Afanasyev" <avv@systema.kiev.ua>
Reply-To: "Vladimir Afanasyev" <avv@systema.kiev.ua>
Subject: Re: Kill a process
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 62.244.14.114 62.244.14.114    
X-Forwarded-For: 192.168.0.147
References:  <3ec399e6@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.65
Message-ID: <3ec3a581$1@newsgroups.borland.com>
Date: 15 May 2003 07:34:41 -0700
X-Trace: newsgroups.borland.com 1053009281 207.105.83.65 (15 May 2003 07:34:41 -0700)
Lines: 36
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!pln-e!extra.newsguy.com!lotsanews.com!panix!dca1-feed2.news.algx.net!dfw3-feed1.news.algx.net!allegiance!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail