Page 1 of 1

Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Mon Nov 30, 2015 11:32 pm
by jmartial
Buenas noches Antonio,

¿ Tienes idea por qué el siguiente código para conocer las carpetas del SO, funciona, pero si la llamo varias veces, al final da una especie de gpf como con el problema del curdir() del anterior mensaje. ?

Creo que tiene relación con la función WideToAnsi, pero no encuentro qué puede ser. Adjunto el código problemático:

Code: Select all  Expand view
HB_FUNC( CESPECIALFOLDERDOMI )
{
  LPTSTR lpszPath = ( LPTSTR ) hb_xgrab( MAX_PATH );
  LPSTR   pAnsi;
  BOOL     bRet ;
                                 // (HWND) GetActiveWindow()
  bRet = SHGetSpecialFolderPath( NULL, lpszPath , (INT) hb_parni(1) , 0 );

  hb_retl( (BOOL) bRet );

  if ( bRet )
   {
      pAnsi = WideToAnsi( ( LPWSTR ) lpszPath );

      if ( ISBYREF( 2 ) )                    // Quitamos el Null del final
         hb_storclen( ( char * ) pAnsi, MAX_PATH, 2 ) ;

      hb_xfree( pAnsi );

   }
  else
   {
      if ( ISBYREF( 2 ) )                    // Mandamos cadena vacía
         hb_storclen( ( char * ) lpszPath, 0 , 2 ) ;
   }

  hb_xfree( lpszPath );

}
 

Re: Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Mon Nov 30, 2015 11:50 pm
by jmartial
Antonio,

Si después de cada llamada a la función anterior, hago una llamada a la función CESysRefresh(), ya funciona por muchas llamadas que haga.

¿De donde podrá venir el problema?

Adjunto función:

Code: Select all  Expand view
HB_FUNC( CESYSREFRESH )
{
  MSG msg;

  if(PeekMessage(&msg, 0, 0, 0, 1))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

  hb_ret();
}

Re: Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Tue Dec 01, 2015 8:33 am
by Antonio Linares
Joaquín,

Mira a ver si te genera un archivo hb_out.log y muéstrame el contenido, gracias

Re: Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Tue Dec 01, 2015 9:44 am
by jmartial
No Antonio,

No genera nada.

Si puedes decirme como generar un fichero de traza de la aplicación para poder detectar errores o pérdidas de memoria, te lo agradecería.

Re: Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Tue Dec 01, 2015 9:50 am
by Antonio Linares
El fichero hb_out.log debería generarlo Harbour automaticamente

Prueba asi:
http://wiki.fivetechsoft.com/doku.php?id=fivewin_function_setresdebug

Re: Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Tue Dec 01, 2015 10:57 am
by jmartial
Antonio,

En fwppc no funciona, genera este error compilando:

error LNK2001: unresolved external symbol HB_FUN_SETRESDEBUG

Re: Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Tue Dec 01, 2015 2:27 pm
by Antonio Linares
Joaquín,

Habría que añadir el módulo checkres.prg de FWH a FWPPC.

Aqui tienes el código
Code: Select all  Expand view
#include "FiveWin.ch"

static aResources := {}

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

function SetResDebug( lOnOff ) // for backwards compatibility

return nil

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

function FWAddResource( nHResource, cType )

   local n := 3, cInfo := ""

   while ! Empty( ProcName( n ) )
      cInfo += ProcName( n ) + "(" + Alltrim( Str( ProcLine( n ) ) ) + ")->"
      n++
   end
   
   if ! Empty( cInfo )
      cInfo = SubStr( cInfo, 1, Len( cInfo ) - 2 )
   endif  
     
   AAdd( aResources, { cType, nHResource, cInfo } )
   
return nil  

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

function FWDelResource( nHResource )

   local nAt

   if ( nAt := AScan( aResources, { | aRes | aRes[ 2 ] == nHResource } ) ) != 0
      ADel( aResources, nAt )
      ASize( aResources, Len( aResources ) - 1 )
   endif    

return nil

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

function CheckRes()

   local cInfo := "", n
   
   for n = 1 to Len( aResources )
      if aResources[ n, 2 ] != 0
         cInfo = GetModuleFileName( GetInstance() ) + " -- " + ;
                 aResources[ n, 1 ] + "," + AllTrim( Str( aResources[ n, 2 ] ) ) + ;
                  "," + aResources[ n, 3 ] + CRLF
         LogFile( "checkres.txt", { cInfo } )
      endif
   next  

   LogFile( "checkres.txt", { GetModuleFileName( GetInstance() ) + " -- " + ;
                              Replicate( "=", 100 ) } )  
   
return nil  

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

#pragma BEGINDUMP

#include <windows.h>
#include <hbapiitm.h>
#include <hbvm.h>

void RegisterResource( HANDLE hRes, LPSTR szType )
{
   PHB_ITEM pRet = hb_itemNew( hb_param( -1, HB_IT_ANY ) );

   hb_vmPushSymbol( hb_dynsymGetSymbol( "FWADDRESOURCE" ) );
   hb_vmPushNil();
   hb_vmPushLong( ( LONG ) hRes );
   hb_vmPushString( szType, strlen( szType ) );
   hb_vmFunction( 2 );

   hb_itemReturnRelease( pRet );
}  

void pascal DelResource( HANDLE hResource )
{
   PHB_ITEM pRet = hb_itemNew( hb_param( -1, HB_IT_ANY ) );

   hb_vmPushSymbol( hb_dynsymGetSymbol( "FWDELRESOURCE" ) );
   hb_vmPushNil();
   hb_vmPushLong( ( LONG ) hResource );
   hb_vmFunction( 1 );

   hb_itemReturnRelease( pRet );
}    

#pragma ENDDUMP

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

Re: Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Tue Dec 01, 2015 2:36 pm
by Antonio Linares
Joaquín,

No es necesario hacer lo que te he comentado.

Simplemente no llames a la función SetResDebug(), no hace falta en FWPPC

El módulo checkres.prg ya está incluido en FWPPC

Re: Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Tue Dec 01, 2015 4:48 pm
by jmartial
Buenas tardes,

El hb_out.log cuando da gpf si lo crea, pero NO en el directorio de la aplicación, sino en el directorio raíz.

Por otro lado, a mi no me genera nada poniendo checkRes() al terminar la aplicación. No sé como se haría.

Re: Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Tue Dec 01, 2015 6:49 pm
by Antonio Linares
Has buscado el fichero checkres.txt ?

Re: Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Wed Dec 02, 2015 9:55 am
by jmartial
Hombre Antonio,

En el escritorio, en el Raíz y en la carpeta de la aplicación.

No existe.

Re: Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Wed Dec 02, 2015 7:10 pm
by Antonio Linares
Joaquín,

Como todo el código está en FWPPC\source\function\checkres.prg podrias poner una traza
en la función CheckRes() para asegurarte de que está pasando por ahí

Re: Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Thu Dec 03, 2015 7:31 pm
by jmartial
Antonio Buenas tardes,

CheckRes.txt se crea perfectamente, unicamente ha sido un error mío, tenía unos defines para depuración y no pasaba por la línea donde ejecutaba checkRes().



Gracias,

Re: Nuevo GPF en win CE 6.0 y fwppc2015

PostPosted: Thu Dec 03, 2015 10:02 pm
by Antonio Linares
muy bien