Is there a way to close a program that was left on purpose open ? I need to close it after the user has finished the current transaction.
Is there a way to close a program that was left on purpose open ? I need to close it after the user has finished the current transaction.
Gustavo,
Do you know the caption of its main window ?
TerminateProcess( GetWindowTask( FindWindow( "window caption", 0 ) ) )
http://msdn.microsoft.com/en-us/library/ms686714(VS.85).aspx
GetWindowTask() is obsolete, according to Microsoft, but keeps working fine ![]()
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
HB_FUNC( TERMINATEPROCESS )
{
hb_retl( TerminateProcess( ( HANDLE ) hb_parnl( 1 ),
IF( PCOUNT() > 1, hb_parni( 2 ), 0 ) ) );
}
#pragma ENDDUMP#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#define IF(x,y,z) ((x)?(y):(z))
HB_FUNC( TERMINATEPROCESS )
{
hb_retl( TerminateProcess( ( HANDLE ) hb_parnl( 1 ),
IF( hb_pcount() > 1, hb_parni( 2 ), 0 ) ) );
}
#pragma ENDDUMPThis line should be this way:
TerminateProcess( GetWindowTask( hTask ), 1 )
ops,
TerminateProcess( GetWndTask( hTask ), 1 )