Solved

DLL API String return value query

Posted on 2004-09-27
6
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 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…

734 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