Link to home
Start Free TrialLog in
Avatar of d_lalit
d_lalit

asked on

DLL API String return value query

Hi,
We are trying to access the following API , present in a particular DLL :
API defined in C:
short EXPORT TblGetValue(char *Param1, char *Param2, void *RetValue)

This API returns the value in the variable 'RetValue'
For Example if we need a value which satifies the conditions passed in Param1 and Param2 the value will be returned in RetVal

Stat = TblGetValue('TESTTBL','TESTKEY',RetStrValue)
The value is returned in the 'RetStrValue' parameter.

Declaration in VB:
public declare function TblGetValue LIB "TABLE32.DLL" (ByVal TblId As String, ByVal KeyId As String, ByRef Value as String) As Integer.

When we try to access this in VB we get a following message :

"Variable uses an automation type not supported in Visual Basic."

Please can anyone let us know the solution to this issue. We are using VB6.0 on Windows 2000.

Thanks

Avatar of EDDYKT
EDDYKT
Flag of Canada image

Try


ByRef Value as any


or


ByRef Value as Variant
Avatar of fds_fatboy
fds_fatboy

Surprisingly I think you have to call it with a ByVal instead of a ByRef
i.e.
public declare function TblGetValue LIB "TABLE32.DLL" (ByVal TblId As String, ByVal KeyId As String, ByVal Value as String) As Integer

This is to do with VB's string pointer handling. You create a buffer and pass the value of the pointer to the start of that buffer. Also, you'll need to fill the Value buffer before you call it.

This may apply:

PRB: Error Compiling VB5 Project Using LPVOID in Type Library
http://support.microsoft.com/default.aspx?scid=kb;en-us;193016

Also, if the C DLL is passing char*, then I believe you must receive it into a byte array, then use the StrConv function to convert it back to inicode.
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial