[Date Prev][Date
Next][Thread Prev][Thread Next][Date
Index][Thread Index]
RE: [OT] - killing a windows process?
Hmm...
I still seem to be struggling... - is this the "mugs game" that
you were
referring to!?...
I have the following code...
sTitle = "HomeSeer"
iHwnd = FindWindow(0&, sTitle)
hThread = GetWindowThreadProcessId(iHwnd, lProcessId)
hProcess = OpenProcess(SYNCHRONIZE, 0&, lProcessId)
iReturn = TerminateProcess(hThread, 0)
I get values returned for all of iHwnd, hThread, and hProcess, but no
matter
what, the terminateprocess command does not kill Homeseer.. (the return
value is always 0, indicating the call failed...)
any ideas?
TIA
Paul G.
>From: "Steve Morgan" <steve@xxxxxxx>
>Reply-To: ukha_d@xxxxxxx
>To: <ukha_d@xxxxxxx>
>Subject: RE: [ukha_d] [OT] - killing a windows process?
>Date: Thu, 6 Mar 2003 18:30:52 -0000
>
>I recently wrote a .NET wrapper for Wserver that I used monitor it and
>kill it if necessary. It was particularly easy because I launched it
>from the wrapper and consequently had a reference to the Process. The
>.NET Framework makes it all rather trivial.
>
>Previously, I've done it using the Win32 API, but I've given it up as a
>mugs game ;-)
>
>In what circumstances do you want to kill HomeSeer?
>
>If you just want to close the app, you can use FindWindow, and post a
>WM_CLOSE message. However, if you want to kill it (perhaps because it's
>hung), you need to FindWindow (or iterate through the windows),
>GetWindowThreadProcessId to get the process ID and terminate the
process
>with TerminateProcess. It's always best to try the WM_CLOSE method
>first, then kill the process if it doesn't respond.
>
>Cheers,
>Steve
>
>
>
> > -----Original Message-----
> > From: Paul Gordon [mailto:paul_gordon@xxxxxxx]
> > Sent: 06 March 2003 16:39
> > To: ukha_d@xxxxxxx
> > Subject: [ukha_d] [OT] - killing a windows process?
> >
> >
> > Question for the win32 programmers among us...
> >
> > (Oh, and the process I want to kill is homeseer.exe, so it's
> > not *totally*
> > OT...)
> >
> > Anyone know how to programatically kill a running process
> > under Windows (XP
> > in this case...). I need to be able to be certain that the
> > process has been
> > terminated completely, just as surely as if I use the task
> > manager GUI and
> > use the "End Process" button...
> >
> > My initial thoughts have been...
> >
> > a) Use the Resource Kit "Kill" utility, - but this is a
bit
> > of a bodge as
> > I'd have to shell out to run it...
> >
> > b) Use the Win32 API directly, this would be my preferred
> > method, but I
> > don't know what call I need, or how to call it from VB. (or
> > even if that is
> > possible?) I'm guessing I need the WM_CLOSE API call? Bear
> > in mind that I
> > don't know the process ID, so I also need to enumerate that
> > at run-time...
> >
> > Any ideas/suggestions? - code snippets... :-)
>
>
>
>http://www.automatedhome.co.uk
>Post message: ukha_d@xxxxxxx
>Subscribe: ukha_d-subscribe@xxxxxxx
>Unsubscribe: ukha_d-unsubscribe@xxxxxxx
>List owner: ukha_d-owner@xxxxxxx
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
_________________________________________________________________
Stay in touch with MSN Messenger http://messenger.msn.co.uk
http://www.automatedhome.co.uk
Post message: ukha_d@xxxxxxx
Subscribe: ukha_d-subscribe@xxxxxxx
Unsubscribe: ukha_d-unsubscribe@xxxxxxx
List owner: ukha_d-owner@xxxxxxx
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Home |
Main Index |
Thread Index
|