RE:Cerrar un proceso en ejecucion
Yo use este codigo que esta en Universalthread. Pero no recuerdo en que programa
FUNCTION KillAnotherProcess
LPARAMETERS tnProcessHandle, tnExitCode
* This is a no-brainer; given the handle of a running process, kill it. Pass the PHANDLE (as returned from CreateProcess()
* in the PROCESS_INFORMATION structure. See LaunchAppAndWait() to see how to extract the handle.
*
* The ExitCode parameter is an integer error level returned by the dead Process. If none is set, we'll pass 0
*
IF TYPE('tnProcessHandle') # 'N'
RETURN .F.
ENDIF
IF TYPE('tnExitCode') # 'N'
tnExitCode = 0
ENDIF
DECLARE TerminateProcess IN WIN32API AS KillProcess ;
INTEGER hProcess, ;
INTEGER fuExitCode
RETURN KillProcess(tnProcessHandle, tnExitCode) = 1
&&&&To get the exit code from a process, try:
FUNCTION ProcessExitCodeWas
LPARAMETER tnProcessToCheck
IF TYPE('tnProcessToCheck') # 'N'
* Process Handles are numbers
RETURN NULL
ELSE
* Maybe we have a process handle, so lets check the ExitCode
DECLARE SHORT GetExitCodeProcess IN WIN32API AS GetExitCodeProc ;
INTEGER hProcess, ;
@INTEGER lpdwExitCode
LOCAL nRetunCode
nReturnCode = 0
IF GetExitCodeProc(tnProcessToCheck, @nReturnCode)
* Got an exit code, even though it might be STILL_ACTIVE
RETURN nReturnCode
ELSE
* Invalid process?
RETURN NULL
ENDIF
ENDIF