FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour GETTASKS
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
GETTASKS
Posted: Sun Jul 17, 2011 07:20 PM

Does gettask work with WINDOWS 7?

Thanks in advance
Otto

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: GETTASKS
Posted: Mon Jul 18, 2011 01:31 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: GETTASKS
Posted: Mon Jul 18, 2011 11:18 PM

Antonio,

Is it possible to give a summary of that Spanish topic. Many of us at the English forum don't understand a single word of Spanish.

Thank you in advance.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: GETTASKS
Posted: Tue Jul 19, 2011 05:28 AM
Michel,

Basically that thread explains how to implement function GetTasks() for 32 and 64 bits as the old way used in FW for Clipper does no longer work in 32/64 mode.

Anyhow, we have included the new function GetTasks() in FWH 11.07, so we can keep using it as we were used to.

This is the final code for it:

Code (fw): Select all Collapse
#include "FiveWin.ch"

static aTasks

//----------------------------------------------------------------------------//

function GetTasks()

   local aTask

   aTasks = {}

   EnumChildWindows( GetDesktopWindow(), { | hWnd | AddTask( hWnd ) } )

   for each aTask in aTasks
      aTask = aTask[ 1 ] + ", " + aTask[ 2 ]
   next

return ASort( aTasks )

//----------------------------------------------------------------------------//

static function AddTask( hWnd )

   local cTaskName := GetWindowModuleFileName( hWnd )
   
   if AScan( aTasks, { | aTask | aTask[ 2 ] == cTaskName } ) == 0
      AAdd( aTasks, { GetWindowText( hWnd ), cTaskName } )
   endif
   
return nil

//----------------------------------------------------------------------------//

#pragma BEGINDUMP

#include <windows.h>
#include <psapi.h>
#include <hbapi.h>

HB_FUNC( GETWINDOWMODULEFILENAME )
{
   HWND hWnd = ( HWND ) hb_parnl( 1 );
   DWORD processId = 0;
   DWORD dwLength = 1024;
   char buffer[ 1024 ];
   HMODULE hProcess;

   GetWindowThreadProcessId( hWnd, &processId );
   hProcess = ( HMODULE ) OpenProcess( 1040, 0, processId );
   dwLength = GetModuleFileNameEx( hProcess, 0, buffer, dwLength );
   CloseHandle( hProcess );
   
   hb_retclen( buffer, dwLength );
}

#pragma ENDDUMP 

//----------------------------------------------------------------------------//
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: GETTASKS
Posted: Tue Jul 19, 2011 10:26 AM

Antonio,

Thanks a lot for your answer.

It's all clear to me now.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Continue the discussion