๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to terminate another program from my application?

#700
From: Bob Gonder
Date: Wed, 27 Feb 2008 01:33
28 lines
2371 bytes
Mads M๏ฟฝlgaard Andersen wrote:

>I get the processID through the enumerattion, I get the process handle, 

>  I call GetExitProcessCode to get the process' exitcode but when I call 

The exit code is STILL_ACTIVE because you haven't terminated the process yet.
IOW this call is irrelevant to the terminator.

>TerminateProcess with the handle and the exitcode it always return FALSE.

Check the GetLastError();

>Then to my surprise I see that you've hardcoded "-9" as exitcode. Is 
>there something I should know here ?

The -9 is what the processess that started the process that you terminated, will see.

Initiating App (perhaps the Win Shell)
	CreateProcess(app that will be terminated)
	WaitFor(app that will be terminated)
	GetExitCodeProcess(hProcess,lpExitCode)

External terminator app does
>>       if(!TerminateProcess(ps,-9))

lpExitCode will be set to -9 when this code executes and terminates(app that will be
terminated)
Technical Details
Message-ID: <bje9s319fi86cr3bjunuh7piph85r3g9d8@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46d17858@newsgroups.borland.com> <46d19c99$1@newsgroups.borland.com> <46d1dde9@newsgroups.borland.com> <46d1deff@newsgroups.borland.com> <46d1f127$1@newsgroups.borland.com> <46d4178d@newsgroups.borland.com> <jcb8d3lj5oke59jhgfapojavmul4jqjapq@4ax.com> <46d572d9@newsgroups.borland.com> <u24bd3drqmfa3llhja42hun4l5u3qvut5f@4ax.com> <46d6076d$1@newsgroups.borland.com> <47c3d946$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,ea27fed4f668a6eb
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: How to terminate another program from my application?
Date: Tue, 26 Feb 2008 17:33:21 -0800
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <bje9s319fi86cr3bjunuh7piph85r3g9d8@4ax.com>
References: <46d17858@newsgroups.borland.com> <46d19c99$1@newsgroups.borland.com> <46d1dde9@newsgroups.borland.com> <46d1deff@newsgroups.borland.com> <46d1f127$1@newsgroups.borland.com> <46d4178d@newsgroups.borland.com> <jcb8d3lj5oke59jhgfapojavmul4jqjapq@4ax.com> <46d572d9@newsgroups.borland.com> <u24bd3drqmfa3llhja42hun4l5u3qvut5f@4ax.com> <46d6076d$1@newsgroups.borland.com> <47c3d946$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: 69.69.80.168
X-Trace: newsgroups.borland.com 1204076000 69.69.80.168 (26 Feb 2008 17:33:20 -0700)
Lines: 30
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail