Calling C++ DLL from VB 
Author Message
 Calling C++ DLL from VB

Hello,
I am a C++ programmer with minimal knowledge of VB. I have a C++ DLL and now
I need to guide our customer on how to call the DLL from his VB system.

My first question: I am testing it on VBA in MS Access. Is there a
difference between VB and VBA ?

And the second question:
In my header file I have the following declarations:

struct S1
{
 double x, y;

Quote:
};

struct S2
{
 int i;
 double x, y;

Quote:
};

In VBA code:

Type S1
    x As Double
    y As Double
End Type

Type S2
    at As Long
    x As Double
    y As Double
End Type

Declare Function test1 Lib "My.dll" (ByRef p1 As S1) As Double
Declare Function test2 Lib "My.dll" (ByRef p2 As S2) As Double

The first function test1 passes parameters forth and back correctly.
The second passes correctly only the first parameter.

Where is a problem ?

Thank, Marek



Tue, 15 Mar 2005 21:41:05 GMT  
 Calling C++ DLL from VB
On Fri, 27 Sep 2002 15:41:05 +0200, "Marek Scholaster"

Quote:

>Hello,
>I am a C++ programmer with minimal knowledge of VB. I have a C++ DLL and now
>I need to guide our customer on how to call the DLL from his VB system.

>My first question: I am testing it on VBA in MS Access. Is there a
>difference between VB and VBA ?

There are differences, but i'll leave that to someone who knows it
better.

Quote:
>And the second question:
>In my header file I have the following declarations:

You need to pack your structs to 4 bytes on the C side.
VB packs to 4 bytes and unfortunately there is no way of changing it.

So it's #pragma pack(4)  /* and  it'll work.  */
struct S1
{
        int i;
        double x,y;

Quote:
};

--
Regards, Frank


Tue, 15 Mar 2005 23:11:03 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. call C++ dll in VB.net

2. calling C++ DLL from VB

3. calling C++ DLL in VB

4. Calling C++ DLL from VB

5. Calling C++ DLLs from VB with string params

6. How do I call C++ DLL in VB?

7. Calling C++ DLLs from VB with string params

8. VB 5.0 calling C++ 5.0 DLL that calls winsock.dll

9. Calling a C++ DLL function which takes an C++ object as parameter

10. Debugging C++ DLL which is called from VB

11. Calling a C++ DLL using vb

12. Instability when calling a C++ DLL from VB.NET

 

 
Powered by phpBB® Forum Software