Article View: borland.public.cppbuilder.nativeapi
Article #11811Re: Terminating An EXE
From: Dave
Date: Fri, 16 Jan 2004 02:33
Date: Fri, 16 Jan 2004 02:33
41 lines
1740 bytes
1740 bytes
On Tue, 13 Jan 2004 19:49:06 +0200, CBoss wrote:
> Hi all,
>
> How can I terminate a program (exe) in code.
>
> For example the program I want to terminate is "TEST.exe",
>
> And the program I want to terminate "TEST.exe" in is "Terminator.exe".
>
> What is the code I need in "Terminator.exe".
>
> Thanks A Lot,
>
> Arif.
Hi Arif,
here's a sample code i wrote some time ago,
it will actually look for a window called test and will
send the app a close message.
Hope it helps.
Dave
int main(int argc, char* argv[])
{
HWND Application = FindWindow( NULL, argv[1]);
if (Application){
SendMessage(Application, WM_CLOSE, 0, 0);
printf("Successfully closed ");
printf(argv[1]);
printf(".\n");}
else{
printf(argv[1]);
printf(" was not found, therefore could not be closed.\n");}
return 0;
}
Technical Details
Message-ID:
<130czj78yobkf.gzyhwlq9ilgm$.dlg@40tude.net>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40042f87@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,b7295d63393a6959 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-01-15 18:39:48 PST From: Dave <dave_xse@hotmail.com> Subject: Re: Terminating An EXE Newsgroups: borland.public.cppbuilder.nativeapi MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit References: <40042f87@newsgroups.borland.com> Date: Fri, 16 Jan 2004 03:33:41 +0100 Message-ID: <130czj78yobkf.gzyhwlq9ilgm$.dlg@40tude.net> User-Agent: 40tude_Dialog/2.0.5.1 NNTP-Posting-Host: 202.173.179.187 X-Trace: newsgroups.borland.com 1074220407 202.173.179.187 (15 Jan 2004 18:33:27 -0700) Lines: 41 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail