Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB Declarations for Client Access API

Posted on 1998-02-15
9
Medium Priority
?
247 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
  • 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 Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Technology Partners: 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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…

972 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