Quantcast
Channel: Visual COBOL
Viewing all articles
Browse latest Browse all 5819

Forum Post: RE: Load a DLL

$
0
0
The error that you are seeing is caused by calling a native .dll that is a different bitism than the calling managed program. If this is a 32-bit .dll that you are calling then the managed code project must be built as type x86 and not x64 or anyCPU. It is unclear from your description what call you are actually trying to make. You show the following call statement:    call "Bematech_FI_ProgramaHorarioVerao"                                               returning cmdstatus. but the function signature that you show does not match that call. It is instead trying to call a function called TrocarCodigoDeAtivacao which takes a number of parameters and returns a native pointer: char * TrocarCodigoDeAtivacao ( int numeroSessao; char * codigoDeAtivacao; int option; char * novoCodigo; char * confNovoCodigo ); If you are trying to call TrocarCodigoDeAtivacao then you should be able to call it like you did in NX native code but because it returns a native pointer you will have to perform a couple of extra steps in order to marshal this into managed memory. The following is an example of how to copy the bytes pointed to by the native pointer into managed code. I didn't know how you had this defined so I guessed. $set ilusing"System.Runtime.InteropServices" 01 numeroSessao  pic s9(9) comp-5. 01  codigoDeAtivacao pic x(100). 01 option pic s9(9) comp-5. 01 novoCodigo pic x(100). 01 confNovoCodigo pic x(100). 01 pData type Byte occurs any. 01 _pDataBlock      type IntPtr 01 ret-params.     05 field1   pic x(2).     05 field2  pic 9(5).    call winapi "TrocarCodigoDeAtivacao"       using by value numeroSessao                by reference codigoDeAtivacao                by value  option                by reference novoCodigo.                                     confNovoCodigo       returning _PDataBlock    end-call    set size of pData to length of ret-params    invoke type Marshal::Copy(_pDataBlock, pData, 0, LENGTH OF ret-params)    set ret-params to pData     ...

Viewing all articles
Browse latest Browse all 5819

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>