Hi all,
I am trying to call a DLL from within PBCC5.0 but keep getting Memory Access Violations when calling BAS_LD_StartTranslate. Sorry I am not that familiar with pointers and such. The (very brief) documentation that came with the DLL for calling it using C says:
where "tranfile" is the filename to be processed and
Buffer = GlobalAlloc(GPTR, LD_GetBufferSize());
my code is:
This compiles just fine but when trying to execute BAS_LD_StartTranslate I get the memory violation exception with the message:
"Program tried to read or write an invalid memory address"
What am I doing wrong?
Thanks in advance
Pablo
I am trying to call a DLL from within PBCC5.0 but keep getting Memory Access Violations when calling BAS_LD_StartTranslate. Sorry I am not that familiar with pointers and such. The (very brief) documentation that came with the DLL for calling it using C says:
Code:
'int LD_GetBufferSize(); ' // returns size of data buffer used by translate functions ' 'int LD_StartTranslate(char *tranfile, void *Buffer); ' // initialize data for translate
Buffer = GlobalAlloc(GPTR, LD_GetBufferSize());
my code is:
Code:
#COMPILE EXE #DIM ALL DECLARE FUNCTION BAS_LD_GetBufferSize SDECL LIB "c:\lardav\slmutil\translatorv323\LDSlmTranslate.dll" _ ALIAS "LD_GetBufferSize" AS LONG DECLARE FUNCTION BAS_LD_StartTranslate SDECL LIB "c:\lardav\slmutil\translatorv323\LDSlmTranslate.dll" _ ALIAS "LD_StartTranslate" (BYVAL tranfile AS DWORD, BYVAL Buffer AS DWORD) AS LONG #INCLUDE "LD_Structures.INC" FUNCTION PBMAIN () AS LONG DIM theBufferSize AS LONG DIM fName AS ASCIIZ * 256 DIM ptr2Bufr AS DWORD' POINTER DIM fnError AS DWORD fName = "c:\lardav\Bin_Test.BIN" ' ' Get the size of the buffer ' theBufferSize = BAS_LD_GetBufferSize () ' returns 9899 ' ' Dimension the buffer based on the returned value from BAS_LD_GetBufferSize() ' // allocate memory for translate DLL internal data ' GLOBALMEM ALLOC theBufferSize TO ptr2Bufr ' ' Call the StartTranslate function to initialize things ' fnError = BAS_LD_StartTranslate ( VARPTR(fName), ptr2Bufr ) END FUNCTION
"Program tried to read or write an invalid memory address"
What am I doing wrong?
Thanks in advance
Pablo
Comment