🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: TerminateProcess and CounterStrike game

#14382
From: Ben Hochstrasser [FF]
Date: Mon, 18 Aug 2003 23:34
37 lines
2307 bytes
George wrote:

> And how someone can terminate this game? Sending WM_CLOSE does not
> work. Other games work fine with TerminateProcess

How about WM_TERMINATE?
Else try to call the ExitProcess() function in the program:

(...)
if DuplicateHandle(GetCurrentProcess, ProcHandle, GetCurrentProcess,
                   @DupHandle, PROCESS_ALL_ACCESS, False, 0) then
begin
  hKernel := GetModuleHandle('Kernel32');
  pfnExitProc := GetProcAddress(hkernel, 'ExitProcess');
  dwTid := 0;
  hRt := CreateRemoteThread(DupHandle, nil, 0, @pfnExitProc, nil, 0,
                            dwTid);
  if hRt <> 0 then
  begin
    // brutal kill
    if WaitForSingleObject(hRt, 10000) = WAIT_TIMEOUT then
      Result := (TerminateProcess(ProcHandle, 0) and
                (WaitForSingleObject(ProcHandle, 10000) <> WAIT_TIMEOUT))
    else
      Result := True;
    CloseHandle(hRt);
  end;
end;
(...)



-- 
Ben

With a disclaimer like the one supplied below by Borland, who needs a 
fancy sig?
Technical Details
Message-ID: <Xns93DCFF0EA735bhoc@207.105.83.65>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!hermes.visi.com!news-out.visi.com!petbe.visi.com!skynet.be!skynet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f4151c6@newsgroups.borland.com> <3f415ab9$1@newsgroups.borland.com> <3f415f65$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,106b55b22f87ee4d
X-Google-Attributes: gid10cc67,public
X-Google-Thread: f94dd,106b55b22f87ee4d
X-Google-Attributes: gidf94dd,public
X-Google-ArrivalTime: 2003-08-18 16:42:35 PST
Newsgroups: borland.public.cppbuilder.nativeapi,borland.public.delphi.nativeapi
Subject: Re: TerminateProcess and CounterStrike game
From: "Ben Hochstrasser [FF]" <bhoc@surfeu123^H^H^H.ch>
References: <3f4151c6@newsgroups.borland.com> <3f415ab9$1@newsgroups.borland.com> <3f415f65$1@newsgroups.borland.com>
Date: Tue, 19 Aug 2003 01:34:01 +0200
Organization: Huh?
Message-ID: <Xns93DCFF0EA735bhoc@207.105.83.65>
Followup-To: borland.public.delphi.nativeapi
User-Agent: Xnews/5.04.25
X-Face: %,ZY>)HcS`@0U'*W5'Lr\8Pm}CVL46h^FG"q2H^O'K*7'W`c%"V\wNgnh$P"Z[B><S3@<-nTt@L=M#+cOawLHm#8q227tM*~jVY*oD3`L2H][7=gNHxQ~(G?`"$FlutE{k3|<FtJhG'uI
NNTP-Posting-Host: 217.162.173.25
X-Trace: newsgroups.borland.com 1061249643 217.162.173.25 (18 Aug 2003 16:34:03 -0700)
Lines: 37
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!hermes.visi.com!news-out.visi.com!petbe.visi.com!skynet.be!skynet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail