Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB Declarations for Client Access API

Posted on 1998-02-15
9
Medium Priority
?
246 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 100 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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

705 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