> > I've never seen an example of code that could find a running process and >terminate it without relying on the window title search. > >If you store _VFP.ProcessID at program start in some file, you can use the >following code to terminate the process. Just replace _VFP.ProcessID with >the handle read from that file: > > Local lnHandle > Declare Long OpenProcess in Win32API ; > Long dwDesiredAccess, ; > Long bInheritHandle, ; > Long dwProcessId > Declare TerminateProcess in Win32API ; > Long hProcess, ; > Long uExitCode > lnHandle = OpenProcess( 1, 0, _VFP.ProcessID ) > TerminateProcess( m.lnHandle, 1 )
Thanks, Christof. Of course, there's the problem of where to place the file... ;-) (Yes, I've received good solutions for that already.) This looks very useful.
>If you need to do this based on the EXE name on all platforms including >Windows NT 4, it's a little bit more work. Here's an article with C++ code >to do this:
Thanks for taking the time to include the article and the code. Fortunately, I don't have to support anything before Win 98.
Ken www.stic-cil.org
©2007 Ken Dibble |