AppCrash Windows 7 al leer INI

AppCrash Windows 7 al leer INI

Postby fgondi » Tue Aug 23, 2022 8:34 pm

Hola,

Estoy complilando con la última version de FWH, Harbour y VS2022

Al trabajar con un INI en Windows 7 o Windows Server 2008, la aplicación devuelve un AppCrash.
En Windows 10, 11 o Server de versión superior, funciona sin problemas.

He probado con \Samples\TestIni.prg y también casca.
En concreto casca en la primera llamada Get
Code: Select all  Expand view
GET cTitle  SECTION "main" ENTRY "Title"   OF oIni DEFAULT "FiveWin App"


el hbp que uso para construir el ejecutable es:
Code: Select all  Expand view
-gui

-Ic:\fwh\include

testini.prg

-Lc:\fwh\lib

-lFiveH32
-lFiveHC32

-lgdiplus
-lole32
-lOleDlg
-lversion

xhb.hbc
hbct.hbc
hbwin.hbc
hbmzip.hbc
hbziparc.hbc
hbfoxpro.hbc

-ldflag=/NODEFAULTLIB:msvcrt


Code: Select all  Expand view
call "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
c:\harbour\bin\hbmk2 sample.hbp -comp=msvc
 
Un saludo
Fernando González Diez
ALSIS Sistemas Informáticos
User avatar
fgondi
 
Posts: 694
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España

Re: AppCrash Windows 7 al leer INI

Postby Antonio Linares » Wed Aug 24, 2022 6:34 am

Fernando,

Por favor comprueba si se genera un fichero hb_out.log y copia el contenido aqui, gracias
regards, saludos

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

Re: AppCrash Windows 7 al leer INI

Postby fgondi » Wed Aug 24, 2022 10:14 am

Hola,

No genera el archivo hb_out.log

Casca en la lectura del primer valor
Code: Select all  Expand view
GET cTitle  SECTION "main" ENTRY "Title"   OF oIni DEFAULT "FiveWin App"
Un saludo
Fernando González Diez
ALSIS Sistemas Informáticos
User avatar
fgondi
 
Posts: 694
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España

Re: AppCrash Windows 7 al leer INI

Postby Antonio Linares » Wed Aug 24, 2022 3:32 pm

Aparece algun error en pantalla o simplemente la aplicación termina ?
regards, saludos

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

Re: AppCrash Windows 7 al leer INI

Postby fgondi » Wed Aug 24, 2022 4:03 pm

Testini.exe dejo de funcionar

Code: Select all  Expand view
Firma con problemas:
  Nombre del evento de problema:    APPCRASH
  Nombre de la aplicación: testini.exe
  Versión de la aplicación:   0.0.0.0
  Marca de tiempo de la aplicación:    630536c3
  Nombre del módulo con errores:   testini.exe
  Versión del módulo con errores: 0.0.0.0
  Marca de tiempo del módulo con errores:  630536c3
  Código de excepción:    c0000005
  Desplazamiento de excepción: 00023249
  Versión del sistema operativo:   6.1.7601.2.1.0.16.7
  Id. de configuración regional:   3082
  Información adicional 1a4a6
  Información adicional 2a4a6d662ea50490d5d34aa5042d56e97
  Información adicional 3: 9aed
  Información adicional 4: 9aede9b28b317395eb1236b114dab4e6

Lea nuestra declaración de privacidad en línea:
  http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0c0a

Si la declaración de privacidad en línea no está disponible, lea la declaración de privacidad sin conexión:
  C:\Windows\system32\es-ES\erofflps.txt
 
Un saludo
Fernando González Diez
ALSIS Sistemas Informáticos
User avatar
fgondi
 
Posts: 694
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España

Re: AppCrash Windows 7 al leer INI

Postby hmpaquito » Wed Aug 24, 2022 4:07 pm

Hola,

Un error recursivo podria estar generando ese problema

Una solucion para detectar el problema es encerrar la operacion de la llamada a la funcion de lectura del ini con un estructura de control de errores y mostrar el error que da. Algo asi como

Code: Select all  Expand view
TRY
   leerArchivoIni()
CATCH oErr
   msgInfo(oErr:Description)
END
 
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: AppCrash Windows 7 al leer INI

Postby fgondi » Wed Aug 24, 2022 7:45 pm

Hola,

Aun así sigue apereciendo el appcrash y no muestra ningún mensaje de error

Code: Select all  Expand view
   TRY
           GET cTitle  SECTION "main" ENTRY "Title"   OF oIni DEFAULT "FiveWin App"
    CATCH oErr
       msgInfo(oErr:Description)
    END
 
Un saludo
Fernando González Diez
ALSIS Sistemas Informáticos
User avatar
fgondi
 
Posts: 694
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España

Re: AppCrash Windows 7 al leer INI

Postby Antonio Linares » Wed Aug 24, 2022 11:11 pm

Fernando,

Por favor prueba a llamar la función del API de Windows directamente:

MsgInfo( GetPvProfString( cSection, cEntry, cValToChar( uDefault ), cIniFile ) )

y comprueba si sucede lo mismo. gracias
regards, saludos

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

Re: AppCrash Windows 7 al leer INI

Postby fgondi » Thu Aug 25, 2022 8:04 am

Code: Select all  Expand view

...
INI oIni FILE ".\MyApp.ini"
? 'a'
MsgInfo( GetPvProfString( "main", "Title", cValToChar( "FiveWin App" ), ".\MyApp.ini" ) )
? 'b'
GET cMsg    SECTION "main" ENTRY "Message" OF oIni DEFAULT "Main message"
...
 


No muestra ningún error adiccional.
Aparece el print a y luego sigue apareciendo el appcrash
No llega al print b
Code: Select all  Expand view
Firma con problemas:
  Nombre del evento de problema:    APPCRASH
  Nombre de la aplicación: testini.exe
  Versión de la aplicación:   0.0.0.0
  Marca de tiempo de la aplicación:    63072c4d
  Nombre del módulo con errores:   testini.exe
  Versión del módulo con errores: 0.0.0.0
  Marca de tiempo del módulo con errores:  63072c4d
  Código de excepción:    c0000005
  Desplazamiento de excepción: 00023bd9
  Versión del sistema operativo:   6.1.7601.2.1.0.16.7
  Id. de configuración regional:   3082
  Información adicional 1a4a6
  Información adicional 2a4a6d662ea50490d5d34aa5042d56e97
  Información adicional 3cb90
  Información adicional 4cb909b3739f584694cfad667b5d174a5

Lea nuestra declaración de privacidad en línea:
  http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0c0a

Si la declaración de privacidad en línea no está disponible, lea la declaración de privacidad sin conexión:
  C:\Windows\system32\es-ES\erofflps.txt
 
Un saludo
Fernando González Diez
ALSIS Sistemas Informáticos
User avatar
fgondi
 
Posts: 694
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España

Re: AppCrash Windows 7 al leer INI

Postby Antonio Linares » Thu Aug 25, 2022 12:21 pm

Fernando,

Este es el código de la función GETPVPROFSTRING()

Puede ser un desbordamiento de pila por el tamaño del buffer (16384). Prueba a poner cantidades mas pequeñas en el tamaño del buffer hasta que desaparezca el crash :-)

Renombra la función para que puedas probarla facilmente sin tener que modificar las librerias de FWH

Code: Select all  Expand view
#ifdef __HARBOUR__
   HB_FUNC( GETPVPROFSTRING )
#else
   HB_FUNC( GETPVPROFS )
#endif
{
   BYTE bBuffer[ 16384 ];
   WORD wLen;

   wLen = GetPrivateProfileString( hb_parc( 1 ),     // Section
                                   IF( HB_ISCHAR( 2 ), hb_parc( 2 ), 0 ),   // Entry
                                   hb_parc( 3 ),     // Default
                                   ( char * ) bBuffer,        // Destination Buffer
                                   sizeof( bBuffer ) - 1,   // M x Len
                                   hb_parc( 4 ) );   // INI File
   if( wLen )
      hb_retclen( ( char * ) bBuffer, wLen );
   else
      hb_retc( "" );
}
 
regards, saludos

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

Re: AppCrash Windows 7 al leer INI

Postby karinha » Thu Aug 25, 2022 3:07 pm

Code: Select all  Expand view

    // MENU PRINCIPAL

    // Para Carregar a Ultima Tela Salva no Arquivo .INI chamar FundoWnd()
    IF FILE( "FUNDO.INI" )
       FUNDOWND() // Chamada ao fundo de tela Escolhida Pelo Usu rio. Muito Bom.
    ELSE
       NOME_ARQ := FCREATE("FUNDO.INI")

       NREGISTRO := "[MAIN]"                                                  ;
                    + CRLF                                    +               ;
                    "Tipo=1"                                  +               ;
                    + CRLF                                    +               ;
                    "Style=BRICKS"                            +               ;
                    + CRLF                                    +               ;
                    "Cor=32768"                               +               ;
                    + CRLF                                    +               ;
                    "File=.\ARANHA.BMP"                       +               ;
                    + CRLF+CRLF                               +               ;
                    "[LOGO]"                                  +               ;
                    + CRLF                                    +               ;
                    "File=.\Logo.bmp"                         +               ;
                    + CRLF                                    +               ;
                    "Row=10"                                  +               ;
                    + CRLF                                    +               ;
                    "Col=10"                                  +               ;
                    + CRLF+CRLF                               +               ;
                    "[THANKS]"                                +               ;
                    + CRLF                                    +               ;
                    "Special Thanks = "+"Ednaldo Rolim"                      +;
                    + CRLF                                                   +;
                    "Propriet rio.. = "+"JoÆo Santos-kapiabafwh@gmail.com.br"+;
                    + CRLF                                    +               ;
                    "Meu Site:..... = "+"Visite: www.pleno.com.br"           +;
                    + CRLF+CRLF                                              +;
                    "Autor......... = "+"JoÆo Santos - kapiabafwh@gmail.com.br"

       FWRITE( NOME_ARQ, NREGISTRO )
       FCLOSE( NOME_ARQ )

       FUNDOWND() // Chamada ao fundo de tela Escolhida Pelo Usu rio. Muito Bom.

    ENDIF
 
    // Enviado Por Ednaldo Rolim, Para Colocar o Logo em 23/11/2002
    // nheight() = Pra Cima Pra Baixo       = -235
    // nWidth()  = Pra Esquerda Pra Direita = -410

    WndCenter( oWndMain:hWnd )

    ACTIVATE WIN...


FUNCTION FundoWnd( nOption, oWin, cWStyle, nWCor )

    LOCAL oIni, oBrush, oBmp
    LOCAL nTipo, cStyle, nCor, cFile, cLogo, nRow, nCol, lSelect
    LOCAL cDiretor := GetPvProfString( "Settings", "SaveDir", FilePath(), ".\FUNDO.INI" )
    LOCAL cMascara := "*.BMP", oImage
    LOCAL Nome_Arq, nRegistro, oDlg, cMsg, cTexto
    LOCAL nResHoriz, nResVert

    DEFAULT nOption := 0, oWin := oWndMain:oWndClient

    IF nOption < 0 .AND. nOption > 4
       RETURN NIL
    ENDIF

    INI oIni FILE ".\Fundo.ini"
        GET nTipo    SECTION "MAIN" ENTRY "Tipo"  OF oIni DEFAULT 1
        GET cStyle   SECTION "MAIN" ENTRY "Style" OF oIni DEFAULT "Bricks"
        GET nCor     SECTION "MAIN" ENTRY "Cor"   OF oIni DEFAULT  nRGB(   0,   0, 255 )
        GET cFile    SECTION "MAIN" ENTRY "File"  OF oIni DEFAULT ".\Aranha.bmp"

        GET cLogo    SECTION "LOGO" ENTRY "File"  OF oIni DEFAULT ".\Logo.bmp"
        GET nRow     SECTION "LOGO" ENTRY "Row"   OF oIni DEFAULT 10
        GET nCol     SECTION "LOGO" ENTRY "Col"   OF oIni DEFAULT 10
    ENDINI

    IF nOption == 0

        lSelect := .F.

     ELSEIF nOption == 1  // Vem do Menu Principal, troca a BMP

        nTipo   := 1
        lSelect := .T.

     ELSEIF nOption == 2

        cStyle  := cWStyle
        nTipo   := 2
        lSelect := .F.

     ELSEIF nOption == 3

        nCor    := nWCor
        nTipo   := 3
        lSelect := .F.

     ELSEIF nOption == 4

        nTipo   := 3
        lSelect := .T.

    ENDIF

    //---- Cria o Brush
    //
    IF nTipo == 1

        IF lSelect // No Windows 7, precisa estar como administrador senao...

           //cFile := SubStr( cGetFile( "*.BMP", "Selecione o Arquivo Bitmap (.BMP)" ), 1 )

           cFile := SubStr( cGetFile( "*.BMP", "Selecione o Arquivo Bitmap (.BMP)" ), 3 )

        ENDIF

        IF Empty( cFile )
           Return Nil
        ENDIF

        // DEFINE BRUSH oBrush FILE cFile

        //SET BRUSH OF oWin TO oBrush // Modificado em: 20/04/2011

        nResHoriz := oWndMain:nHorzRes() // retorna a resolucao horizontal
        nResVert  :=  oWndMain:nVertRes() // retorna a resolucao vertical

        IF nResHoriz     = 1440 .AND. nResVert = 900

           @ 0, 0 IMAGE oImage SIZE 1440, 668 OF oWin ADJUST
           oImage:Progress( .F. )
           oImage:LoadBmp( cFile )

        ELSEIF nResHoriz     = 1366 .AND. nResVert = 768

           @ 0, 0 IMAGE oImage SIZE 1366, 668 OF oWin ADJUST
           oImage:Progress( .F. )
           oImage:LoadBmp( cFile )

        ELSEIF nResHoriz     = 1360 .AND. nResVert = 768

           @ 0, 0 IMAGE oImage SIZE 1360, 668 OF oWin ADJUST
           oImage:Progress( .F. )
           oImage:LoadBmp( cFile )

        ELSEIF nResHoriz = 1280 .AND. nResVert = 768

           @ 0, 0 IMAGE oImage SIZE 1280, 668 OF oWin ADJUST
           oImage:Progress( .F. )
           oImage:LoadBmp( cFile )

        ELSEIF nResHoriz = 1280 .AND. nResVert = 720

           @ 0, 0 IMAGE oImage SIZE 1280, 668 OF oWin ADJUST
           oImage:Progress( .F. )
           oImage:LoadBmp( cFile )


        ELSEIF nResHoriz = 1280 .AND. nResVert = 960

           @ 0, 0 IMAGE oImage SIZE 1280, 668 OF oWin ADJUST
           oImage:Progress( .F. )
           oImage:LoadBmp( cFile )

        ELSEIF nResHoriz = 1280 .AND. nResVert = 800

           @ 0, 0 IMAGE oImage SIZE 1280, 668 OF oWin ADJUST
           oImage:Progress( .F. )
           oImage:LoadBmp( cFile )

        ELSEIF nResHoriz = 1280 .AND. nResVert = 720

           @ 0, 0 IMAGE oImage SIZE 1280, 668 OF oWin ADJUST
           oImage:Progress( .F. )
           oImage:LoadBmp( cFile )

        ELSEIF nResHoriz = 1280 .AND. nResVert = 600

           @ 0, 0 IMAGE oImage SIZE 1280, 668 OF oWin ADJUST
           oImage:Progress( .F. )
           oImage:LoadBmp( cFile )

        ELSEIF nResHoriz = 1600 .AND. nResVert = 1200

           @ 0, 0 IMAGE oImage SIZE 1600, 668 OF oWin ADJUST
           oImage:Progress( .F. )
           oImage:LoadBmp( cFile )

        ELSEIF nResHoriz = 1680 .AND. nResVert = 1050

           @ 0, 0 IMAGE oImage SIZE 1680, 668 OF oWin ADJUST
           oImage:Progress( .F. )
           oImage:LoadBmp( cFile )

        ELSEIF nResHoriz = 2560 .AND. nResVert = 1600

           @ 0, 0 IMAGE oImage SIZE 2560, 668 OF oWin ADJUST
           oImage:Progress( .F. )
           oImage:LoadBmp( cFile )

        ELSEIF nResHoriz = 1024 .AND. nResVert = 768

           IF ISWINXP()

              @ 0, 0 IMAGE oImage SIZE 1024,668 OF oWin ADJUST
              oImage:Progress( .F. )
              oImage:LoadBmp( cFile )

           ELSE

              @ 0, 0 IMAGE oImage SIZE 1024,678 OF oWin ADJUST
              oImage:Progress( .F. )
              oImage:LoadBmp( cFile )

           ENDIF

        ELSE

           IF ISWINXP()

              @ 0, 0 IMAGE oImage SIZE 800,500 OF oWin ADJUST
              oImage:Progress( .F. )
              oImage:LoadBmp( cFile )

            ELSE

              @ 0, 0 IMAGE oImage SIZE 800,510 OF oWin ADJUST
              oImage:Progress( .F. )
              oImage:LoadBmp( cFile )

           ENDIF

        ENDIF

     ELSEIF nTipo == 2

        DEFINE BRUSH oBrush STYLE ( cStyle )

     ELSEIF nTipo == 3

        IF lSelect
           nCor := ChooseColor()
        ENDIF

        DEFINE BRUSH oBrush COLOR nCor

    ENDIF

    //---- Estabelece o Brush da Janela
    //
    IF nTipo != 1

       SET BRUSH OF oWin TO oBrush

    ENDIF

    IF nOption != 0

        // Grava no Arquivo INI as Modifica‡äes
        INI oIni FILE ".\Fundo.ini"

            SET SECTION "MAIN" ENTRY "Tipo"  OF oIni TO nTipo
            SET SECTION "MAIN" ENTRY "Style" OF oIni TO cStyle
            SET SECTION "MAIN" ENTRY "Cor"   OF oIni TO nCor
            SET SECTION "MAIN" ENTRY "File"  OF oIni TO cFile

            SET SECTION "LOGO" ENTRY "File"  OF oIni TO cLogo
            SET SECTION "LOGO" ENTRY "Row"   OF oIni TO nRow
            SET SECTION "LOGO" ENTRY "Col"   OF oIni TO nCol

            SET SECTION "THANKS" ENTRY "Special Thanks" ;
                OF oIni TO "Ednaldo Rolim - ednaldorolim@uol.com.br - My Friend"
            SET SECTION "THANKS" ENTRY "Autor..." ;
                OF oIni TO "JoÆo Santos   - kapiabafwh@gmail.com.br"
            SET SECTION "THANKS" ENTRY "Meu Site:....." ;
                OF oIni TO "Visite: www.pleno.com.br"

        ENDINI

        // REINICIAR O PROGRAMA PARA ASSUMIR A NOVA TELA DE FUNDO

        IF nOption == 1

           MsgInfo( OemToAnsi( "Aten‡Æo Usu rio:             " )+CRLF+  ;
                    OemToAnsi( "PRECISO REINICIAR O PROGRAMA " )+CRLF+  ;
                    OemToAnsi( "Tecle <ENTER> Para Continuar " ),       ;
                    OemToAnsi( "Tecle <Enter> Para Finalizar " ) )

           MsgRun( "Desligando o Programa...           ", ;
                   "Por Favor, Espere!                 ", ;
                   { | oDlg | ( DESLIGA_VENDAS( oDlg ) ) } )

           AEVAL(DIRECTORY( "VENDAS.BAT"     ),{ |aFILE| FERASE(aFILE[F_NAME]) } )

           IF .NOT. FILE( "VENDAS.BAT" )

              NOME_ARQ := FCREATE("VENDAS.BAT")

              NREGISTRO := "@ECHO OFF"                                       ;
                           + CRLF        +                                   ;
                           "CLS"         +                                   ;
                           + CRLF + CRLF +                                   ;
                           "VENDAS.EXE"  +                                   ;
                           + CRLF + CRLF +                                   ;
                           "CLS"         +                                   ;
                           + CRLF        +                                   ;
                           "EXIT"

              FWRITE( NOME_ARQ, NREGISTRO )
              FCLOSE( NOME_ARQ )

           ENDIF

           DbCloseAll()

           WinExec( "VENDAS.BAT", 0 )

           __Quit()

        ENDIF

    ENDIF

RETURN NIL
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7353
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: AppCrash Windows 7 al leer INI

Postby fgondi » Fri Aug 26, 2022 8:49 am

Hola,

Sólo con incluir esta función en el código fuente, ya funciona sin problemas.
No he tenido que cambiar el buffer

Code: Select all  Expand view
#pragma BEGINDUMP

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

#define IF(x,y,z) ((x)?(y):(z))
   
   #ifdef __HARBOUR__
       HB_FUNC( GETPVPROFSTRING )
    #else
       HB_FUNC( GETPVPROFS )
    #endif
    {
       BYTE bBuffer[ 16384 ];
       WORD wLen;

       wLen = GetPrivateProfileString( hb_parc( 1 ),     // Section
                                       IF( HB_ISCHAR( 2 ), hb_parc( 2 ), 0 ),   // Entry
                                       hb_parc( 3 ),     // Default
                                       ( char * ) bBuffer,        // Destination Buffer
                                       sizeof( bBuffer ) - 1,   // M x Len
                                       hb_parc( 4 ) );   // INI File
       if( wLen )
          hb_retclen( ( char * ) bBuffer, wLen );
       else
          hb_retc( "" );
    }

#pragma ENDDUMP
Un saludo
Fernando González Diez
ALSIS Sistemas Informáticos
User avatar
fgondi
 
Posts: 694
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 39 guests