Click to See Complete Forum and Search --> : Using VC++ 6 Classes in DLL in VB6


KyleK
July 25th, 2000, 08:38 AM
I have created a DLL in VC++ 6 that has 3 classes and is used for a simple file conversion. One classe performs all of the work, while the other 2 classes are used within the first one. The main class has a function called Convert() that performs all of the work, but I don't know how to call that function from within VB 6. What do I have to do since the function is a part of a Class and not stand-alone??

={ S. Kyle Korndoerfer }=

Lothar Haensler
July 25th, 2000, 09:20 AM
two options:
- turn your VC app into a DLL and create an extern "C" style function that can be exported and call it from VB via a Declare & call statement

- turn your VC app into an ActiveX DLL, an automation component. VB can call COM components via CreateObject...

KyleK
July 27th, 2000, 10:20 AM
I am relatively new to creating Active X/COM objects, but have read up on a basic ATL COM object and incorporated it into Visual Basic. I am however at a slight lose when it comes to applying my classes in this manner. I have one class that does all of the work with 2 support classes, ie...

OCC2RR
|--> List
|--> Node

The OCC2RR class contains all of the functions to perform the actual conversion via a call to a function called Convert(). How would I go about creating the ATl COM object for this example? Or am I missing a more simplistic approach?

={ S. Kyle Korndoerfer }=

KyleK
July 27th, 2000, 04:09 PM
Nevermind.. I have built the ATL COM object, incorporated it into VB, and it is working.

The only hurdle left to clear is being able to pass the filename and path to the ATL COM Object so that it will work with any file selected by the user. Any quick suggestions?

={ S. Kyle Korndoerfer }=

Lothar Haensler
July 28th, 2000, 02:01 AM
I am NOT an ATL expert.
In an MFC Appwizard bases ActiveX dll I'd simply expose a public method that takes a BSTR as an argument and stores that value in a class member variable.

July 28th, 2000, 01:30 PM
Lothar is rught pass the Filename and path as a BSTR. Keep in mind if you have a path C:\Windows\System32\crackers.dll

the slashes mean somthing in C++ for example "print this line \n on two lines"

the \n means new line. So before you pass the filename and path you may have to change it to look like c:\\Windows\\System32\\crackers.dll

Wasn't sure if you were having problems passing the filename or just didn't know what type to make it. I would test this because I can't remeber if you have to use \\ in a bstr or can get by with a single \.