Creating Objects in VB from C++ DLL 
Author Message
 Creating Objects in VB from C++ DLL

I can call functions on the DLL fine...i just need to create an object in VB
of the class defined in the C++ DLL...

I can call this funtion and get the value back fine...This funtion belongs
to the CCustomerInfoRS Class, so that means the DLL is fine and
working....And I can use it in VB
Private Declare Function ReturnNumber Lib "..\ServerDLL.dll" () As Integer

There is a class in the DLL called CCustomerInfoRS, and I need to create an
object of that class in my vb app.
Do I need to tell VB that the DLL is there? how so? The declare statment
allows me to use functions in the DLL but does that open the connection and
tell VB that the DLL is there?

When I try to do this...I get User-Type not Defined, like it is not looking
in the DLL for my class....
'Dim MyObject As CCustomerInfoRS
'Set MyObject = New CCustomerInfoRS

Or This...
'Dim MyObject As Object
'Set MyObject = CCustomerInfoRS

I have tried to regester my DLL but it is not registerable... get an invalid
Entrypoint error...I used VC++6.0 wizard to create it...I just added the
class and such...But i can use it already so i don't think this is the
problem...

Please I am at a stalemate...I have no idea how to do this...i am not a VB
pro i know more C++... any help is appreciated...

Thanks,
Joel Prine



Mon, 11 Jul 2005 23:52:41 GMT  
 Creating Objects in VB from C++ DLL
[All of the following assumes VB5/6, not VB.Net.  You should post to
 a different group if your question applies to .Net.]

Quote:

> I can call functions on the DLL fine...i just need to create an object in VB
> of the class defined in the C++ DLL...

> I can call this funtion and get the value back fine...This funtion belongs
> to the CCustomerInfoRS Class, so that means the DLL is fine and
> working....And I can use it in VB
> Private Declare Function ReturnNumber Lib "..\ServerDLL.dll" () As Integer

I'm a little curious about how you're going about it that a member
function is called through Declare and works correctly.  This would
need to be a static member (non-static members would not work right),
and even then I'm not sure how you export it undecorated.

Also, it's unlikely that Integer is the correct return type -- most
likely it should be Long, which corresponds to the C++ int type
(VB Integer == C++ short).

Quote:
> There is a class in the DLL called CCustomerInfoRS, and I need to create an
> object of that class in my vb app.

Then you must wrap that C++ class in COM.  VB does not understand
vanilla C++ classes.  I'd recommend using ATL, personally, but it can
also be done using MFC or, if you're really {*filter*}ic, by hand with
no framework support.

You could either convert your C++ class into a COM class, or you could
forward from the COM implementation into the plain C++ implementation.

Also note that VB requires automation-compatible classes, which means
that all object parameters must be either automation-compatible
interfaces or dual interfaces and all other parameters must be things
which can be stuffed in a Variant.  You should add the oleautomation
attribute to the IDL for the class if you don't make it a dual
interface.



Wed, 13 Jul 2005 00:30:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. accessing objects in a c++ DLL from a c++ activeX control placed in a VB application

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

3. Creating a C++ object in VB???

4. how to create C++ object in VB?

5. Steps to instantiate COM objects created in VB in C++

6. Create C++ class DLL with VB ?

7. Creating a wrapper/dll for my C++ code to interface with VB

8. Creating C++ DLL's for VB

9. Create borland c++ dll and call from vb

10. Problem with VB 4.0 using dll created with borland c++

11. HELP: Creating DLL for VB using Borland C/C++

12. Creating DLLs with VC/C++ for VB

 

 
Powered by phpBB® Forum Software