Article View: borland.public.cppbuilder.nativeapi
Article #4083Re: Terminate Process started by CreateProcess
From: JD
Date: Tue, 28 Mar 2006 09:41
Date: Tue, 28 Mar 2006 09:41
28 lines
1986 bytes
1986 bytes
"Binzhong Zhou" <Binzhong.Zhou@csiro.au> wrote: > > Could some one tell how I can safely terminate an application > started by CreateProcess? If you look in the win32.hlp file for CreateProcess and examine the LPPROCESS_INFORMATION parameter, you'll see that that pointer is used to pass back information about the new process in the form of a PROCESS_INFORMATION structure which has a dwProcessId member that you can use to accomplish what you want. When your application closes, use the win32 API EnumWindows to enumerate all of the windows. In the callback function for EnumWindows, use the win32 API GetWindowThreadProcessId and compare the returned ID to the dwProcessId member of the PROCESS_INFORMATION structure and if they match then use the win32 API SendMessage to send a WM_CLOSE message to that window. > [...] Based on the help, TerminateProcess is obviously > not recommanded. What is alternative? If any of the processes do not have a window, you'll have to brute force it with TerminateProcess. ~ JD
Technical Details
Message-ID:
<442912e4$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder.xsnews.nl!216.196.110.148.MISMATCH!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4428b7bf$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,28ca43e529050a9d X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "JD" <nospam@nospam.com> Sender: "JD" <nospam@nospam.com> Reply-To: "JD" <nospam@nospam.com> Subject: Re: Terminate Process started by CreateProcess Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 205.188.116.136 X-Forwarded-For: 172.136.37.122 References: <4428b7bf$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <442912e4$1@newsgroups.borland.com> Date: 28 Mar 2006 02:41:40 -0700 X-Trace: newsgroups.borland.com 1143542500 207.105.83.66 (28 Mar 2006 02:41:40 -0700) Lines: 29 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder.xsnews.nl!216.196.110.148.MISMATCH!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail