DLL Experts on Vacation? 
Author Message
 DLL Experts on Vacation?

I thought maybe that subject would garner a few looks -- my earlier
posting drew no replies.

Somewhere between VB3 and VB5 (or 16-bitness and 32-bitness), the
order of passing parameters seems to have changed.  My VB3 program
called my 16-bit Borland C++ DLL with args listed in the same order
between the VB declaration and the C++ function declaration.  But in
VB5 and the 32-bit flavor of the same DLL, the parameters must be
listed in the opposite order.

Anybody know why?

Thanks
Tom



Mon, 21 Aug 2000 03:00:00 GMT  
 DLL Experts on Vacation?


Quote:
>I thought maybe that subject would garner a few looks -- my earlier
>posting drew no replies.

>Somewhere between VB3 and VB5 (or 16-bitness and 32-bitness), the
>order of passing parameters seems to have changed.  My VB3 program
>called my 16-bit Borland C++ DLL with args listed in the same order
>between the VB declaration and the C++ function declaration.  But in
>VB5 and the 32-bit flavor of the same DLL, the parameters must be
>listed in the opposite order.

>Anybody know why?

The VB argument declarations should be in the same order as in C++.
The most likely reason for reversal of arguments is the use of struct
parameters in C++.
For example:

The C++ declaration

        ... dllfunc(POINT p, int n) { ... }

where the structure POINT is defined as

        struct POINT { int x, y; };

would be in VB3

        Declare Sub dllfunc ... (y as Integer, x as Integer, n as Integer)

and in VB5

        Declare Sub dllfunc ... (x as Long, y as Long, n as Long)

Henry S. Takeuchi

Seattle, Washington (USA)



Mon, 21 Aug 2000 03:00:00 GMT  
 DLL Experts on Vacation?

: Somewhere between VB3 and VB5 (or 16-bitness and 32-bitness), the
: order of passing parameters seems to have changed.  My VB3 program
: called my 16-bit Borland C++ DLL with args listed in the same order
: between the VB declaration and the C++ function declaration.  But in
: VB5 and the 32-bit flavor of the same DLL, the parameters must be
: listed in the opposite order.

The switch seems to have happened in the 16 vs. 32 bit versions of VB4.
The 16-bit version uses the Pascal calling convention (first arg passed
first, no underscores, called routine cleans up the stack).  Since 16-bit
DLLs are also compiled as PASCAL, everything works out great.

The 32-bit version, however, switched to the _stdcall calling convention
(same as extern "C", I think).  This switches the order of several things,
i.e. last arg passed first, generate underscores, and calling routine
cleans up the stack.

This information can be found in the VB4DLL.TXT file in the app's directory.
--
============================================================================
Mike Carmack                    |  Vulcan Dragon -==(UDIC)==-
Oracle Certified Professional   |  http://www.netcom.com/~mr_worf/vulcan.htm



Tue, 22 Aug 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Calling all ASP/VB DLL experts!

2. Question for the experts (ActiveX DLL's without references)

3. Duplicate database fields in report expert, select expert...

4. Calling a DLL - question for experts

5. For a VB and DLL expert

6. For a VB or DLL Expert

7. EXPERT NEEDED -- Export a DLL Function

8. Your Vacation in SE Asia

9. Need Vacation, Need $$$$

10. Vacation Money

11. Mexico Beach House Vacation trade (or $$) for VBA-ADO cyber consulting

12. Tracking Employee Vacation Time in Outlook

 

 
Powered by phpBB® Forum Software