FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to kill a process
Posts: 365
Joined: Sat Oct 08, 2005 07:59 PM
How to kill a process
Posted: Thu Aug 31, 2006 08:01 PM

Upon starting an application, I would like to be able to kill a certain process or app that shows in the Task Manager as FtLnSOP.exe. Manually, I can do it by right clicking it and asking "Kill the process tree". Is there any way of achieving the same from the program?
Thanks
Rafael

Posts: 1076
Joined: Fri Oct 07, 2005 10:41 PM
Re: How to kill a process
Posted: Fri Sep 01, 2006 03:51 AM
Rafael Clemente wrote:Upon starting an application, I would like to be able to kill a certain process or app that shows in the Task Manager as FtLnSOP.exe. Manually, I can do it by right clicking it and asking "Kill the process tree". Is there any way of achieving the same from the program?
Thanks
Rafael


Este link te puede servir

Utilizando wmi, se pueden hacer muchas cosillas

Saludos
William, Morales

Saludos



méxico.sureste
Posts: 142
Joined: Sun Oct 09, 2005 10:59 AM
How to kill a process
Posted: Fri Sep 01, 2006 08:37 AM
Rafael

Here you have an example.

In this example shellexecute starts wordpad with efkes.rtf. The use has to close this aplication first before continuing. If this not occured , the program will do that.

Shellexecute(0 ,0  , "C:\TEMP\efkes.rtf" ,0 ,0 , 1)          
hWnd := FINDWND( "EFKES.RTF" ) 
			
? "Atention , wordpad must be closed correctly"
      
DO WHIL .T.
    hWnd := FINDWND( "EFKES.RTF" ) 

    IF ! EMPTY( hWnd ) 
       ? "the aplication closes Winword"  
        SENDMESSAGE( hWnd, 16 ) 
    End
END
Posts: 142
Joined: Sun Oct 09, 2005 10:59 AM
Missing FindWnd()
Posted: Fri Sep 01, 2006 11:32 AM
// from http://fivetechsoft.com/forums/viewtopic.php?t=1346&start=0&postdays=0&postorder=asc&highlight=findwindow%2A 
#define GW_HWNDFIRST 0 
#define GW_HWNDLAST  1 
#define GW_HWNDNEXT  2 
#define GW_HWNDPREV  3 
#define GW_OWNER     4 
#define GW_CHILD     5 

FUNCTION FINDWND( cTitle ) 

LOCAL hWnd := GETWINDOW( GETDESKTOPWINDOW(), GW_CHILD ) 

WHILE hWnd != 0 
    IF UPPER( cTitle ) $ UPPER( GETWINDOWTEXT( hWnd ) ) 
        RETURN hWnd 
    ENDIF 

    hWnd = GETWINDOW( hWnd, GW_HWNDNEXT ) 
ENDDO 

RETURN NIL
Posts: 365
Joined: Sat Oct 08, 2005 07:59 PM
How to kill a process
Posted: Fri Sep 01, 2006 11:43 AM

Frank:

Thank you for your suggestion. The problem is that I do not know the Window title of the program to kill; only its name as it appears in the Task Manager, i.e: "FtLnSOP.exe"

Any other suggestion? Oskar's sollution seems promising, but at present I have been unabe to compile his example (see Spanish Forum).

Regards,

Rafael

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How to kill a process
Posted: Fri Sep 01, 2006 12:39 PM

Rafael,

You may use TerminateProcess()

http://support.microsoft.com/default.as ... us;178893

&

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
How to kill a process
Posted: Sat Sep 02, 2006 07:09 PM

If I must terminate many processes but I not Know how many application are in process, but only these processes not mine program ...
How I can make it ?

Can I have an small sample,pls ?

Best Regards, Saludos



Falconi Silvio
Posts: 365
Joined: Sat Oct 08, 2005 07:59 PM
How to kill a process
Posted: Sat Sep 02, 2006 10:18 PM

Same for me, pls

Rafael

Posts: 365
Joined: Sat Oct 08, 2005 07:59 PM
How to kill a process
Posted: Sun Sep 03, 2006 08:12 AM

Oskar:
Muchííííísimas gracias. Funciona perfecto. Es justo lo que yo necesitaba
Un saludo
Rafael

Continue the discussion