Solved

DLL API String return value query

Posted on 2004-09-27
6
209 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

860 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