Solved

DLL API String return value query

Posted on 2004-09-27
6
206 Views
Last Modified: 2010-05-02
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

0
Comment
Question by:d_lalit
6 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12159149
Try


ByRef Value as any


or


ByRef Value as Variant
0
 
LVL 10

Expert Comment

by:fds_fatboy
ID: 12159192
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.

0
 
LVL 32

Expert Comment

by:Erick37
ID: 12159818
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.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12642553
PAQed with no points refunded (of 50)

modulo
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now