Solved

VB Declarations for Client Access API

Posted on 1998-02-15
9
245 Views
Last Modified: 2012-06-27
Can you give me the VB5 declaration for the following C prototype ?

unsigned int  cwbRC_GetParm(char     *program,
                                                       unsigned short      index,
                                                       unsigned short     *type,
                                                       unsigned long      *length,
                                                       unsigned char     **parameter);

         
ATTENTION to **parameter  
(double pointer) my favourite
                                                            Thanks            
       
0
Comment
Question by:withanat
[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
  • 4
  • 4
9 Comments
 
LVL 5

Expert Comment

by:dirtdart
ID: 1457210
Unfortunatly, that won't be possible.  The int and char type themselves don't convert to VB, and there are no unsigned types currently supported by VB.  Not to mention that VB doesn't supply pointers, although a single pointer can be made to work.  If you'd like, I can translate it into something that will work.
0
 

Expert Comment

by:dpms
ID: 1457211
Now I don't think all is lost here. VB allows for passing by reference (though if your passing a string out of VB you would pass it by value, and a string is a string in VB whether it holds one character or dozens). The short data type is compatible with the integer data type in VB (though couldn't say for sure as to the "unsigned" issue - but it still might work). I say play around with it before you throw in the towel. This is REALLY on the fly... but maybe something like this:

sub cwbRC_GetParm(byval program as string,
                   index as integer,
                   byref type as integer,
                   byref length as long,
                   byval parameter as string) as integer
end sub
0
 

Expert Comment

by:dpms
ID: 1457212
oops... byval on the "index as integer" parameter
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 5

Expert Comment

by:dirtdart
ID: 1457213
You're half right, dpms.  You can pass byref.  That's what I meant when I said "a single pointer can be made to work."  However, your declaration above will not work.  The C int type is not compatible with the Visual Basic Integer type, and the C char type is not compatible with a Visual Basic String.  If you got the above declaration to even call without crashing both programs, all you would get in return is total garbage.
0
 

Author Comment

by:withanat
ID: 1457214
I have no trouble with unsigned int, long or string etc. There are other declarations that use them.
My problem is with ** (double pointer). Last parm


0
 
LVL 5

Accepted Solution

by:
dirtdart earned 50 total points
ID: 1457215
The only way to get a double pointer from VB would be to change the C declaration to accept a single pointer.  Then pass the parameter from VB ByRef.  Once you get it into the dll, you will have to create a pointer from that pointer and use that as your parameter.
0
 

Expert Comment

by:dpms
ID: 1457216
I agree the double pointer is tricky and that a single pointer would have to be used. But I still hold my ground that the "short" type in C is compatible with the integer type in VB, but I did have to clarify about the "unsigned" part of the parameter.
0
 
LVL 5

Expert Comment

by:dirtdart
ID: 1457217
Short does convert to Integer.  But I'm not sure what you're going to get when dealing with unsigned.  Personally, I haven't had any luck converting to types that aren't completly supported.  But if you know how to make it work, that's great.
0
 

Expert Comment

by:dpms
ID: 1457218
Below is a table I copied off the MSDN. I myself have successfully passed an integer from VB to a short in C.
According to what I've gone back and read in MSDN, the unsigned
short should also work. Hope this helps..........


The following table shows the data-type equivalencies for both 16- and 32-bit Windows.
 
Visual Basic data type      
Size of variable      16-bit Windows data types      32-bit Windows data types
                  
                  int, short, WCHAR
Integer      2 bytes            WORD, HWND, HANDLE,         short, WCHAR
                                          
                                          
Long      4 bytes            long, LPSTR                int,HWND,                                                        long, HANDLE
                                                    LPSTR       

If your DLL code uses the int data type with arguments either passed in or returned to Visual Basic code, you must change those arguments to use the short data type.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

631 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