Re: using dlls
- Posted by "Elliott S. de Andrade" <quantum_analyst at hotmail.com> Nov 16, 2003
- 622 views
Well, there seems to be a few problems. Firstly, you don't need win32lib.ew to define DLL functions, you should be using dll.e. For d1 and e1, you are including the parameters in the name. Also, the functions that have (void) do not take any parameters. Another thing you may not have found is that the functions have underscores prepended to them. This means that they probably use the C calling convention. This doesn't cause a problem when you define the function, but when you call it, it would probably crash. That means you will need to use eu 2.4. The only way to get around that is to re-compile the DLL. Here's some fixed code: include dll.ew atom ad, a1,b1,c1,d1,e1 ad = open_dll("dxsoftex.dll") a1 = define_c_func(ad,"+_DxsoftExchangeInit", {C_INT}, C_INT) b1 = define_c_func(ad,"+_DxsoftGetSymFromRxBuffer",{}, C_INT) c1 = define_c_func(ad,"+_DxsoftPutSymToTxBuffer",{C_CHAR}, C_INT) d1 = define_c_func(ad,"+_DxsoftGetSymFromTxBuffer",{}, C_INT) e1 = define_c_func(ad,"+_DxsoftPutSymToRxBuffer",{C_CHAR}, C_INT) printf(1, "%d\n%d\n%d\n%d\n%d\n%d\n", {ad, a1, b1, c1, d1, e1}) >From: Rubens Monteiro Luciano <rml at rubis.trix.net> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: using dlls >Date: Sun, 16 Nov 2003 02:31:21 -0200 > > >Hi all ! > I'm just starting using external dlls and need some help. > >The dll is dxsoftex.dll (from <http://www.dxsoft.com/dxs-exch.zip> )and >the functions are these: > >--int DxsoftExchangeInit(int canal_number); >--int DxsoftGetSymFromRxBuffer(void); >--int DxsoftPutSymToTxBuffer(char sym); >--int DxsoftGetSymFromTxBuffer(void); >--int DxsoftPutSymToRxBuffer(char sym); > >the code: > >include win32lib.ew >atom ad >integer a1,b1,c1,d1,e1,a > >ad = open_dll("dxsoftex.dll") >puts(1,sprint(ad)&"\n") ------ ad gives 9895936 > >a1 = define_c_func(ad,"DxsoftExchangeInit", {C_INT}, C_INT) >puts(1, sprint(a1)&"\n") >b1 = define_c_func(ad,"DxsoftGetSymFromRxBuffer",{C_CHAR}, C_INT) >puts(1, sprint(b1)&"\n") >c1 = define_c_func(ad,"DxsoftPutSymToTxBuffer",{C_CHAR}, C_INT) >puts(1, sprint(c1)&"\n") >d1 = define_c_func(ad,"DxsoftGetSymFromTxBuffer(void)",{C_CHAR}, C_INT) >puts(1, sprint(d1)&"\n") >e1 = define_c_func(ad,"DxsoftPutSymToRxBuffer(char sym)",{C_CHAR}, C_INT)= > >puts(1, sprint(e1)&"\n") > > >I stopped here because a1..e1 gives every time only the value -1 >which means that these functions "could not be found". >What am I doing wrong ? > >Thanks > >Rubens >