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 !
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 !
Comment