Bug in TerminateProcess() and/or GetWndTask() function(s) ?

Bug in TerminateProcess() and/or GetWndTask() function(s) ?

Postby HunterEC » Sat Nov 29, 2008 9: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 ?
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Postby Antonio Linares » Sat Nov 29, 2008 9:50 pm

Gustavo,

Here you have a working example, implemented in a different way:
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby HunterEC » Sat Nov 29, 2008 9: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.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Postby HunterEC » Sat Nov 29, 2008 10:44 pm

Antonio:

Thank you very much, with the SendMessage() function worked perfectly ! :D
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 74 guests