Re: Accessing EHLLAPI DLL files
- Posted by pete_stoner at btconnect.com Sep 10, 2003
- 605 views
Thats what I call a quick reply, thanks Matt, you're a star! Time for me to do some more playing........... ----- Original Message ----- From: "Matt Lewis" <matthewwalkerlewis at yahoo.com> To: "EUforum" <EUforum at topica.com> Subject: RE: Accessing EHLLAPI DLL files > > > > From: pete_stoner at btconnect.com [mailto:pete_stoner at btconnect.com] > > > >The EHLLAPI entry point (hllapi) is always called with the following > > >four > > parameters: > > >1.EHLLAPI Function Number (input) > > >2. Data Buffer (input/output) > > >3. Buffer Length (input/output) > > >4. Position (input); Return Code (output) > > > The prototype for the EHLLAPI is; (long hllapi(LPINT, > > LPSTR, LPINT, > > LPINT)" > > > Each parameter is passed by reference not by value...... (etc etc) > > > > My first problem is that I always get an error (-1) from my > > define_c_function . The function I am calling is not listed > > in the DLL I have to call, I am assuming that it must be in > > another DLLs that the first one links to (?), also the book > > says I have to call the function by number (I still don't > > fully understand if I am defining it correctly) i.e. ehlapi = > > open_dll("EHLAPI32.DLL") ConnectPS = define_c_func(ehlapi, > > "1", {C_INT, C_POINTER, C_INT}, C_INT) > > > > The ref book goes on to say.. > > >All the parameters in the hllapi call are pointers and the > > return code > > >of > > the EHLLAPI function is returned in the value of the 4th > > parameter, not as the value of the function.. Which would > > suggest that I cannot get the return code with just the > > normal ret = c_func(ConnectPS.... > > OK, let's start with the function prototype: > > long hllapi(LPINT, LPSTR, LPINT,LPINT) > > This tells us that it returns a long value (probably an error indicator for > hllapi itself, not the function you're calling). The other parameters are > all pointers, do your define_c_func should look like: > > xhllapi = define_c_func( elhapi, "hllapi", repeat(C_POINTER,4), C_INT ) > > Any function you want to call, you will need to call through the hllapi > function. First, you need to allocate space in order to poke the values for > hllapi: > > func_no = allocate(4) > buffer = allocate( 256 ) > buffer_len = allocate(4) > position_return = allocate(4) > > Then poke the values for the function (assuming that ConnectPS is function > #1): > > poke4( func_no, 1 ) > poke( buffer, your_input_data ) > poke4( buffer_len, 256 ) > poke4( position_return, whatever_this_means ) > > ret = c_func( xhllapi, {func_no,buffer,buffer_len,position_return} ) > > -- to see what the return value was: > ? peek4s( position_return ) > > > You should use whatever buffer size that makes sense. Also, you should > check it after calling, because hllapi will probably tell you if it needs > more room to return whatever it was going to return in the buffer (if > anything--you'll have to read the documentation on each routine). I'm not > sure what #4, Position means to hllapi, so I can't help you out there. > > Matt Lewis > > --^---------------------------------------------------------------- > This email was sent to: pete_stoner at btconnect.com >