FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bug in TerminateProcess() and/or GetWndTask() function(s) ?
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
Bug in TerminateProcess() and/or GetWndTask() function(s) ?
Posted: Sat Nov 29, 2008 09:24 PM
I'm trying to close a FiveWin application (caption = 6.0) from another but it's not working.

TerminateProcess( GetWndTask( FindWindow ( , "6.0" ) ), 1 )
OR
hWnd := FindWindow(, "6.0" )
<--- this gets the correct window handle
hTask := GetWndTask( hWnd )
<--- this fails, getting the wrong number

Isn't GetWndTask( hWnd) supposed to get the process id ?


TerminateProcess( hTask , 1 )
<--- this fails because of the wrong hTask

Any clues ?
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Bug in TerminateProcess() and/or GetWndTask() function(s) ?
Posted: Sat Nov 29, 2008 09:50 PM
Gustavo,

Here you have a working example, implemented in a different way:
#include "FiveWin.ch" 

function Main() 

   local oDlg

   DEFINE DIALOG oDlg TITLE "Test" 

   @ 1, 1 BUTTON "Calculator" OF oDlg SIZE 50, 13 ACTION WinExec( "calc" )
   
   @ 1, 12 BUTTON "Close" OF oDlg ;
      ACTION SendMessage( FindWindow( 0, "Calculator" ), WM_CLOSE )

   ACTIVATE DIALOG oDlg CENTERED 

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
Bug in TerminateProcess() and/or GetWndTask() function(s) ?
Posted: Sat Nov 29, 2008 09:52 PM
Antonio:

This: hWnd := FindWindow( "6.0" ) returns 0

This: hWnd := FindWindow(, "6.0" ) returns 265412

Now, this: MsgInfo( GetWndTask( hWnd ) ) returns 3760 that does not shows up in Windows' Task Manager's Processes.

Thank you for your help.
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
Bug in TerminateProcess() and/or GetWndTask() function(s) ?
Posted: Sat Nov 29, 2008 10:44 PM

Antonio:

Thank you very much, with the SendMessage() function worked perfectly ! :D

Continue the discussion