New FWH 13.07 revised build

User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: New FWH 13.07 revised build

Post by Antonio Linares »

It seems as the right solution would be to use dynamic binding:

DLL FUNCTION GetModuleFileNameEx( nHandle AS LONG, nModule AS LONG, cFileName AS LPSTR, nSize AS LONG ) AS LONG LIB "psapi.dll"
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
lucasdebeltran
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am
Contact:

Re: New FWH 13.07 revised build

Post by lucasdebeltran »

Antonio,

I am afraid it does not work.

What change did you make in FW 13.07 please?.

Can you please revert it?.

Thank you.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: New FWH 13.07 revised build

Post by Antonio Linares »

Lucas,

We have not changed anything regarding GetTasks() in FWH 13.07

Why do you think we did a change ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
fgondi
Posts: 636
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España
Contact:

Re: New FWH 13.07 revised build

Post by fgondi »

Antonio,

Como que no se ha cambiado nada?
En la versión 13.06 funcionaba bien en cualquier sistema operativo.

GetTasks() devolvía un array con todas las tareas activas de windows.

Ahora tengo que redefinir GetTasks() devolviendo un array vacio para que no de error.
Func GetTasks()
return {}
Un saludo
Fernando González Diez
ALSIS GHE Sistemas Informáticos
User avatar
fgondi
Posts: 636
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España
Contact:

Re: New FWH 13.07 revised build

Post by fgondi »

Buscando en el código antiguo, he encontrado como lo tenia definido antes de que la función fuera incorporada a fivewin

Lo siento, lo que no tengo es el nombre del maestro que la compartió:

Code: Select all

  // Returns an array with the names of all the active Tasks running in Windows
    //----------------------------------------------------------------------------//
    function GetTasks()

        local hWnd   := GetWindow( GetActiveWindow(), GHW_HWNDFIRST )
        local aTasks := {}
        local cTask,oLdGetTasks:=.T.,hLib32:=0,RetByte:=0,BufTask

    // Verify if the API exist if not it's Windows 95 or Less
    // or Windows NT with SP2 or less so we will use the old technique

        if ABS(hLib32:=Loadlib32("USER32.DLL")) > 32 // Can be Windows 3.11 or Lower
          if substr(Getproc32(hLib32,"GetWindowModuleFileNameA",.T.,LONG,),1,4)<> CHR(0)+CHR(0)+CHR(0)+CHR(0)
            oLdGetTasks:=.f.
            BufTask:=space(200)
          endif
          Freelib32(hLib32)
        endif

        while hWnd != 0
          if oLdGetTasks
           #ifdef __CLIPPER__
              cTask = GetModuleFileName( GetWindowWord( hWnd, GWW_HINSTANCE ) )
           #else
              // cTask = GetModuleFileName( GetWindowLong( hWnd, GWW_HINSTANCE ) )
              cTask = GetWindowText( hWnd ) // The above does now work :-(
           #endif
          else
            Retbyte:=GetWModFileName( hWnd, BufTask, 200 )
            cTask:=left(BufTask,Retbyte)
          endif
          if ! Empty(cTask)
            if AScan( aTasks, cTask ) == 0
              AAdd( aTasks, cTask )
            endif
          endif
          hWnd = GetWindow( hWnd, GHW_HWNDNEXT )
        end

    return aTasks

    //----------------------------------------------------------------------------//
    DLL32 FUNCTION GetWModFileName(  hWnd AS LONG, cBuf AS LPSTR, nLong AS LONG ) ;
                    AS LONG PASCAL FROM "GetWindowModuleFileNameA" LIB "USER32.DLL"
Con este código funciona correctamente en windows xp.
Last edited by fgondi on Tue Aug 20, 2013 7:48 am, edited 1 time in total.
Un saludo
Fernando González Diez
ALSIS GHE Sistemas Informáticos
User avatar
lucasdebeltran
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am
Contact:

Re: New FWH 13.07 revised build

Post by lucasdebeltran »

Antonio,

And why it worked fine under 13.06 and not under 13.07?.

The problema happens only in XP.

Thanks.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: New FWH 13.07 revised build

Post by Antonio Linares »

Fernando,

Ese código funciona bien porque hace enlace dinámico como comenté aqui:

http://forums.fivetechsupport.com/viewt ... 36#p149936

Da igual que usemos un modo u otro, el caso es que se enlace en tiempo de ejecución y no al construir el EXE.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: New FWH 13.07 revised build

Post by Antonio Linares »

Con este cambio en gettasks.prg, ya funciona correctamente en XP, y Win8. No lo he probado aún en Win7.

No ha hecho falta usar enlace dinámico :-)

Code: Select all

#pragma BEGINDUMP

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

#ifdef __GNUC__ 
   WINBASEAPI DWORD WINAPI GetWindowModuleFileName( HWND, LPTSTR, DWORD ); 
#endif

HB_FUNC( GETWINDOWMODULEFILENAME )
{
   #ifndef _WIN64
      HWND hWnd = ( HWND ) hb_parnl( 1 );
   #else   
      HWND hWnd = ( HWND ) hb_parnll( 1 );
   #endif
   
   DWORD dwLength = 0;
   char buffer[ 1024 ];

   dwLength = GetWindowModuleFileName( hWnd, buffer, dwLength );

   hb_retclen( buffer, dwLength );
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
fgondi
Posts: 636
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España
Contact:

Re: New FWH 13.07 revised build

Post by fgondi »

Antonio,

He copiado el código en el prg principal y no funciona.

Sobre Windows 7 devuelve un array vacio
Sobre Windows 2000 sigue apareciendo el error al ejecutar la aplicación.
Un saludo
Fernando González Diez
ALSIS GHE Sistemas Informáticos
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: New FWH 13.07 revised build

Post by Antonio Linares »

Fernando,

Puedes probar esta versión de GetTasks() ? gracias

Code: Select all

#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 := Space( 100 )
   
   GetWindowModuleFileName( hWnd, cTaskName, 100 )
   
   if AScan( aTasks, { | aTask | aTask[ 2 ] == cTaskName } ) == 0
      AAdd( aTasks, { GetWindowText( hWnd ), cTaskName } )
   endif
   
return nil

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

DLL FUNCTION GetWindowModuleFileName( hWnd AS LONG, cName AS LPSTR, nLen AS LONG ) ;
   AS LONG PASCAL FROM "GetWindowModuleFileNameA" LIB "user32.dll"
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
fgondi
Posts: 636
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España
Contact:

Re: New FWH 13.07 revised build

Post by fgondi »

Antonio,

Sobre windows 7, funciona bien
Sobre windows 2000, funciona bien (Funciona la aplicación y funciona la función con las tareas iniciadas)
Un saludo
Fernando González Diez
ALSIS GHE Sistemas Informáticos
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: New FWH 13.07 revised build

Post by Antonio Linares »

En Windows 8 y XP tambien parece funcionar bien :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
norberto
Posts: 566
Joined: Thu Aug 30, 2007 3:40 pm
Location: BR

Re: New FWH 13.07 revised build

Post by norberto »

Antonio, I have the Fwh1307 revised, i need to include this fix, any more after the release of the revised? Thank you

Norberto
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: New FWH 13.07 revised build

Post by Antonio Linares »

Norberto,

This is the most recent GetTasks() code:
http://forums.fivetechsupport.com/viewt ... 10#p150010
regards, saludos

Antonio Linares
www.fivetechsoft.com
norberto
Posts: 566
Joined: Thu Aug 30, 2007 3:40 pm
Location: BR

Re: New FWH 13.07 revised build

Post by norberto »

Antonio, thanks, everything I need, from what I understand, is the revised version more the gettasks, right?
Post Reply