use dlls created with vc++ in vb 
Author Message
 use dlls created with vc++ in vb

hi

i developed a small dll in vc++ using objects with the default vc++ dll
template

how can i instance the object in the dll from my vb project

thanks



Thu, 27 Mar 2003 03:00:00 GMT  
 use dlls created with vc++ in vb

alexhguerra,

In a VB project, from the 'Project' menu choose the 'References...' command.
Browse for your Dll using the browse button.  Add it to the list and make
sure it is ticked.  Your dll is now added to your VB project.  To
instantiate it ...

Private mobjMyDLL As MyDLL.ObjectWithInTheDLL

'==========================================================
Private Sub Class_Initialize()

    set mobjMyDLL = New MyDLL.ObjectWithInTheDLL
End Sub
'==========================================================
.
.
'==========================================================
Private Sub Class_Terminate()

    set mobjMyDLL = Nothing
End Sub
'==========================================================


Quote:
> hi

> i developed a small dll in vc++ using objects with the default vc++ dll
> template

> how can i instance the object in the dll from my vb project

> thanks



Fri, 28 Mar 2003 03:00:00 GMT  
 use dlls created with vc++ in vb

Quote:

> In a VB project, from the 'Project' menu choose the 'References...' command.
> Browse for your Dll using the browse button.  Add it to the list and make
> sure it is ticked.  Your dll is now added to your VB project.  To
> instantiate it ...

> Private mobjMyDLL As MyDLL.ObjectWithInTheDLL

Yes, but if it's really the default VC++ DLL template, it's not a COM
DLL.  VB does not know how to instantiate VC++ objects in DLLS (which
may include templates and true inheritance), or it didn't last I knew.
Quote:


> > i developed a small dll in vc++ using objects with the default vc++ dll
> > template



Fri, 28 Mar 2003 03:00:00 GMT  
 use dlls created with vc++ in vb

Quote:

> i developed a small dll in vc++ using objects with the default vc++ dll
> template

> how can i instance the object in the dll from my vb project

If they're normal C++ objects, that's just not going to work.  VB won't
be able to understand them.

You have two options:
- Export global methods that act on objects that are internal to the
  DLL.  The global methods should be declared as __stdcall.  If you
  set it up right, you might be able to pass "handles" to internal
  objects out to VB, where they are pointers on the C++ side and longs
  on the VB side.  This would require use of type-casting on the C++
  side and consequently you'd lose type safety when they get passed
  back to C++ from VB (i.e. if you{*filter*}it up, it's very likely to
  GPF on you rather than failing gracefully).

- Export COM objects from the DLL.  This is NOT trivial.  It's probably
  easiest to do it using the ATL and associated wizards.  I've never
  done it myself, so I shan't offer any advice.



Fri, 28 Mar 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Calling VC++ programs and VC created dlls from VB

2. can you create a dll in VB and call in VC

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

4. Creating a VC dll for use in VB

5. How to create DLL for subtractio in vc++ and how to call in it in

6. Using VB DLLs OCXs with VC

7. VC -> VB .DLL using safearrays

8. problem: vc++ dll and vb

9. Need help passing a DC handle from vb to a vc++ dll

10. VC++ DLL throws an exception OLEAUT.DLL when used in VB.

11. Using the vb component in vc++

12. create dll VC++6.0 can access functions in

 

 
Powered by phpBB® Forum Software