Call C++ Class member function in a DLL ?? 
Author Message
 Call C++ Class member function in a DLL ??

Does anyone out there have any experience in calling C++ class member
functions in a DLL from VB ??

If you do, then I am very interested in hearing from you. I need to build
a DLL using C++ classes with a Visual Basics front end.  At this point I
don't know if this is possible. How would you reference a class member
function from VB?



Sat, 03 Oct 1998 03:00:00 GMT  
 Call C++ Class member function in a DLL ??

Quote:

>Does anyone out there have any experience in calling C++ class member
>functions in a DLL from VB ??
>If you do, then I am very interested in hearing from you. I need to build
>a DLL using C++ classes with a Visual Basics front end.  At this point I
>don't know if this is possible. How would you reference a class member
>function from VB?

As far as I know, this is semi-impossible - the C++ compiler mangles
the names of all functions - including class member functions. For
regular (non-member) functions, you can get around this by using
declaring them as extern "C" :

extern "C" {
   myFunc(...);

Quote:
}

This doesn't work for member functions.

I've dodged the problem by declaring some intermediate functions that
don't do anything but call the member functions:

extern "C" {
   CallTheMember(...);

Quote:
}

CallTheMember(...)
{
   return Object.MemberFunction(...);

Quote:
}

Of course, you have to watch your return types!

hth
gordo



Mon, 05 Oct 1998 03:00:00 GMT  
 Call C++ Class member function in a DLL ??

Quote:

>Does anyone out there have any experience in calling C++ class member
>functions in a DLL from VB ??
>If you do, then I am very interested in hearing from you. I need to build
>a DLL using C++ classes with a Visual Basics front end.  At this point I
>don't know if this is possible. How would you reference a class member
>function from VB?

Use OLE Automation


Mon, 05 Oct 1998 03:00:00 GMT  
 Call C++ Class member function in a DLL ??

Quote:

>Does anyone out there have any experience in calling C++ class member
>functions in a DLL from VB ??
>If you do, then I am very interested in hearing from you. I need to build
>a DLL using C++ classes with a Visual Basics front end.  At this point I
>don't know if this is possible. How would you reference a class member
>function from VB?

As far as I know, this is semi-impossible - the C++ compiler mangles
the names of all functions - including class member functions. For
regular (non-member) functions, you can get around this by using
declaring them as extern "C" :

extern "C" {
   myFunc(...);

Quote:
}

This doesn't work for member functions.

I've dodged the problem by declaring some intermediate functions that
don't do anything but call the member functions:

extern "C" {
   CallTheMember(...);

Quote:
}

CallTheMember(...)
{
   return Object.MemberFunction(...);

Quote:
}

Of course, you have to watch your return types!

hth
gordo



Thu, 08 Oct 1998 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Call a C++ member function

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

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

4. Calling VBA dll functions with C or C++

5. How do you call a Visual C++ (DLL) function from Visual Basic

6. Calling Visual C++ 5.0 DLL Functions From Visual Basic 5.0

7. Calling a VB function from within a C++ DLL interrupt

8. VB calling C++ Dll function twice?

9. Calling a VB function/procedure from Visual C++ DLL

10. Calling a function in a C++ Win32 Dll from VB 6

11. Calling a VB function from a C++ DLL

12. C++ member functions and VB

 

 
Powered by phpBB® Forum Software