1. DLL Function which returns values in input parameters
- Posted by Rad <radhx at rediffmail.com> Nov 06, 2006
- 556 views
Hi, I am evaluating a software called 1Way which converts any application into a time-bound trial ware using dll's. All the functions of the provided dll work fine except one. The dll has a function which requires 11 parameters and returns already stored Registration Details. First 2 parameters are input values of string type viz. "Serial Number" and the "Password" used to generate it. The next 9 parameters are of integer type and used by the function to return various registration details in it. Return value of function is True or False. (Note: the actual return values are part of input values provided to function) The structure of function in my application is as follows-
xregGetSerialInfo = registerw32Function(syndreg, "GetSerialInfo", {C_POINTER, C_POINTER, C_INT, C_INT, C_INT, C_INT, C_INT, C_INT, C_INT, C_INT, C_INT}, C_UINT)
The same function structure in the C program Header provided with the software demo is as follows- typedef bool ( __stdcall *pGetSerialInfo )( char*, char*, int, int, int, int, int, int, int, int, int ); The Demo provided with the software works fine giving back the registered details written by my application. But when this function is evoked in my application in Euphoria 3.0.1,
RegOptions = 0 SerialExpire = 0 SerialExpireDay = 0 SerialExpireMonth = 0 SerialExpireYear = 0 RegExpire = 0 RegExpireDay = 0 RegExpireMonth = 0 RegExpireYear = 0 if w32Func(xregGetSerialInfo, {regKey, SrlPass, RegOptions, SerialExpire, SerialExpireDay, SerialExpireMonth, SerialExpireYear, RegExpire, RegExpireDay, RegExpireMonth, RegExpireYear}) then void = message_box("SerialInfo OK", "Msg", 0) else void = message_box("SerialInfo NOT OK !!!", "Msg", 0) end if
I get following error- D:\EUPHORIA\Win32Lib\Include\w32dll.ew:212 in function w32Func() A machine-level exception occurred during execution of this statement funcid = 304 parms = {820204,819788,0,0,0,0,0,0,0,0,0} lRC = <no value> libfunc = <no value> lFuncDef = 15 linked = <no value> memset = 1252492 i = 11 ... called from D:\EUPHORIA\Projects\Syndicate ODBC\Test.ew:60 Can anybody guide me solving this issue? Regards, Rad.
2. Re: DLL Function which returns values in input parameters
- Posted by Chris Bensler <bensler at nt.net> Nov 06, 2006
- 562 views
Anytime a function has output parameters, as is the case with this function, those params are pass by reference and must be preallocated. RegOptions = allocate(4) -- INT SerialExpire = allocate(4) -- INT SerialExpireDay = allocate(4) -- INT SerialExpireMonth = allocate(4) -- INT SerialExpireYear = allocate(4) -- INT RegExpire = allocate(4) -- INT RegExpireDay = allocate(4) -- INT RegExpireMonth = allocate(4) -- INT RegExpireYear = allocate(4) -- INT Chris Bensler ~ The difference between ordinary and extraordinary is that little extra ~ http://empire.iwireweb.com - Empire for Euphoria
3. Re: DLL Function which returns values in input parameters
- Posted by "Greg Haberek" <ghaberek at gmail.com> Nov 06, 2006
- 567 views
> RegOptions = allocate(4) -- INT > SerialExpire = allocate(4) -- INT > SerialExpireDay = allocate(4) -- INT > SerialExpireMonth = allocate(4) -- INT > SerialExpireYear = allocate(4) -- INT > RegExpire = allocate(4) -- INT > RegExpireDay = allocate(4) -- INT > RegExpireMonth = allocate(4) -- INT > RegExpireYear = allocate(4) -- INT You must then use peek4u() to read each value from its location in memory. i.e.
atom pRegOptions, -- pointer vRegOptions -- value -- allocate vars pRegOptions = allocate( 4 ) -- INT -- call function -- read values vRegOptions = peek4u( pRegOptions ) -- free memory free( pRegOptions ) -- use values
4. Re: DLL Function which returns values in input parameters
- Posted by Rad <radhx at rediffmail.com> Nov 07, 2006
- 561 views
Hi Chris & Greg, Thanks guys for the help. I could get the function working using allocate() and peek4u(). Thanks once again. Regards, Rad. Greg Haberek wrote: > > > RegOptions = allocate(4) -- INT > > SerialExpire = allocate(4) -- INT > > SerialExpireDay = allocate(4) -- INT > > SerialExpireMonth = allocate(4) -- INT > > SerialExpireYear = allocate(4) -- INT > > RegExpire = allocate(4) -- INT > > RegExpireDay = allocate(4) -- INT > > RegExpireMonth = allocate(4) -- INT > > RegExpireYear = allocate(4) -- INT > > You must then use peek4u() to read each value from its location in memory. > > i.e. > > }}} <eucode> > atom pRegOptions, -- pointer > vRegOptions -- value > > -- allocate vars > pRegOptions = allocate( 4 ) -- INT > > -- call function > > -- read values > vRegOptions = peek4u( pRegOptions ) > > -- free memory > free( pRegOptions ) > > -- use values > </eucode> {{{ > >