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"
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"
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.
Lucas,
We have not changed anything regarding GetTasks() in FWH 13.07
Why do you think we did a change ? thanks
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 {}
聽// 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"Antonio,
And why it worked fine under 13.06 and not under 13.07?.
The problema happens only in XP.
Thanks.
Fernando,
Ese c贸digo funciona bien porque hace enlace din谩mico como coment茅 aqui:
viewtopic.php?p=149936#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.
#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 ENDDUMPAntonio,
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.
#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"Antonio,
Sobre windows 7, funciona bien
Sobre windows 2000, funciona bien (Funciona la aplicaci贸n y funciona la funci贸n con las tareas iniciadas)
En Windows 8 y XP tambien parece funcionar bien ![]()
Antonio, I have the Fwh1307 revised, i need to include this fix, any more after the release of the revised? Thank you
Norberto
Antonio, thanks, everything I need, from what I understand, is the revised version more the gettasks, right?