[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

Importing C++ classes in Visual Basic

Is it possible to import a class exported from a Visual C++ DLL into Visual Basic (either 4.0 or 5.0)?  If so how is this done?
0
berven
Asked:
berven
  • 3
  • 2
1 Solution
 
bervenAuthor Commented:
Edited text of question
0
 
rmichelsCommented:
It is not possible to import a C++ class into VB and use it as a class. I offer up two suggestions on how to use C++ classes in VB.  

1) Implement the C++ class as an activeX object.

2) Write straight 'C' wrappers around the C++ classes.  Have the C funtions return a pointer (just a long) to the C++ classes managed by the C routines.  That was your VB can at least have a handle to a class, allowing multiple instances of classes to be created, but only the C funtion know how to interpret the handle.
0
 
bervenAuthor Commented:
Thank you.  I was hoping I cound get away without having to wrap the class or implement it as an activeX object.
 
I read an article by Bruce McKinney called Extending Visual Basic with C++ DLL's (Microsoft Press April 1996) which led me to hope that this feature may be available in VB5.

Do you know if any other compilers (Borland Delphi or Borland Builder) can import C++ classes?
0
 
rmichelsCommented:
No feature has been added to VB5 that I know of regarding directly using classes from a C++ dll.  There are name mangling issues, stack frame issues (the this pointer).  I have never used Delphi, so I can't speak to that tool.

Creating an ActiveX control with Microsoft Visual C 5.0 is not that difficult.  Microsoft provides wizards that create a class that has all of the required guts for an activex control and you add your own functionality as needed.
0
 
bervenAuthor Commented:
I will give the ActiveX control a try.  Thanks again.
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now