Announcement

Collapse
No announcement yet.

Problem with correct declaring DLL !

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with correct declaring DLL !

    Hi everybody,

    I need to access this DLL function with Powerbasic:

    "C declaration"

    int DLLATO17GeraArquivo (char *szArquivoBinario, char *szArquivoTexto,
    char *szPeriodoIni, char *szPeriodoFIM, char TipoPeriodo, char *szUsuario,
    char *szTipoLeitura);

    "Visual Basic 6 declaration"

    Declare Function DLLATO17GeraArquivo Lib "ATO17.dll" (_
    ByVal szArquivoBinario As String, _
    ByVal szArquivoTexto As String, _
    ByVal szPeriodoIni As String, _
    ByVal szPeriodoFIM As String, _
    ByVal TipoPeriodo As Byte, _
    ByVal szUsuario As String, _
    ByVal szTipoLeitura As String) As Long

    "Powerbasic declaration that I'm trying"
    DECLARE FUNCTION DLLATO17GeraArquivo LIB "ATO17.DLL" _
    ALIAS "DLLATO17GeraArquivo" (_
    szArquivoBinario AS ASCIIZ, _
    szArquivoTexto AS ASCIIZ, _
    szPeriodoIni AS ASCIIZ, _
    szPeriodoFin AS ASCIIZ, _
    bTipoPeriodo AS BYTE, _
    szUsuario AS ASCIIZ, _
    szTipoLeitura AS ASCIIZ) AS LONG


    The problem is that when I call this function in VB6, works fine, but when I call the function in PB9, I get this message in the debug window:

    "
    Exception: Memory Access Violation
    Program tried to read or write an invalid memory address
    "

    - I tried to change the declaration to return "Integer", and... no success.
    - I tried to change the declaration of the "byte" var to:
    "BYVAL bTipoPeriodo AS BYTE", and... no success either.

    I'm thinking that the problem is only on the declaration of the "byte" var, because, on the same DLL, there are other functions that expect ASCIIZ parameters and they work fine.

    Here's how I'm calling the function:
    ...
    DIM szNomeMFD AS ASCIIZ * 1024
    DIM szNomeArquivo AS ASCIIZ * 1024
    DIM szPeriodoIni AS ASCIIZ * 8
    DIM szPeriodoFim AS ASCIIZ * 8
    DIM bTipoPeriodo AS BYTE
    DIM szUsuario AS ASCIIZ * 10
    DIM szTipoLeitura AS ASCIIZ * 10
    DIM ret AS LONG
    ...
    ret = DLLATO17GeraArquivo( _
    szNomeMFD, _
    szNomeArquivo, _
    szPeriodoIni, _
    szPeriodoFim, _
    bTipoPeriodo, _
    szUsuario, _
    szTipoLeitura)


    Any help would be appreciated.

    Thanks,
    Happy 2009 !

  • #2
    I'm thinking that the problem is only on the declaration of the "byte" var
    You're right. Use BYVAL bTipoPeriodo AS BYTE.
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Jose,

      I've already done that, with no success.
      The correct way is what you said (BYVAL).
      I discovered the bug, the function uses one file that was corrupted. Deleting the file and creating it again solved my problem.

      Thanks for your help.
      Gilmar.

      Comment


      • #4
        discovered the bug, the function uses one file that was corrupted. Deleting the file and creating it again solved my problem
        There is no such thing as "corrupt input," there are only missed edits.
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          I meant that the function uses internally one binary file that was corrupted !

          Thanks.

          Comment

          Working...
          X