|
-
December 2nd, 1999, 09:30 AM
#1
Passing parameters to a C DLL
I'm having trouble passing parameters in VB to a DLL which was created in C.
returned values are ok if no parameters are passed, but the error:
"Bad calling convention"
appears each time I try to pass parameters
my C function header is
MYDLL_API int add(int x, int y)
in VB, I have the line to link to the DLL as
private Declare Function add Lib "mydll.dll" (byval f as Integer, byval s as Integer) as Integer
option Explicit
the function itself contains the lines
txtAnswer.text = add(5,4)
Any Idea?
Thanks for any help.
-
December 2nd, 1999, 09:36 AM
#2
Re: Passing parameters to a C DLL
IMHO you should consider the following changes:
- a VB Integer is 2 bytes, a C int in 32-Bit-World is 4 bytes. Thus DECLARE the VB arguments "As Long"
- use stdcall calling convention in your C declaration
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|