Re: Class export by regular DLL (vc++) be used in vb

From: Ralph (msnews.20.nt_consulting32_at_spamgourmet.com)
Date: 12/07/04


Date: Tue, 7 Dec 2004 08:51:14 -0600


"polybear" <poly@mega> wrote in message
news:%23mLBZJC3EHA.2012@TK2MSFTNGP15.phx.gbl...
>
> I had a simple class export by regular DLL written by vc++,
> Other develop tool like VB are going to use it.
> But i don't know how the refernce/declare the class in VB ....
>
> Can i use this class in VB directly , or should i pack this class
> into ActiveX or COM object format then reference it in VB IDE?
>
> What is the difference between ActiveX and COM in usage?
>

A little confused by your question, as you appear to be referring to two
separate entities.

A 'regular' DLL refers to a dynamic library which exports functions (using
the WINAPI convention). There are two basic methods to use these functions
in your VB app.
1) Use the Declare Function directive to declare them in your VB code, or
2) Create a typelib for the DLL and reference that in your app.

Of the two, IMHO, a type library is the only way to go, unless you are only
going to import a few functions. (Using the Declare statement adds to the
size of a program, is mildly slower than using a type library, and can lead
to subtle errors if you aren't consistent.)

But then you mention "classes". There is no simple way to use (import) a C++
class (native or MFC) in a VB application. The easiest and sanest way is to
wrap the c++ classes with an ActiveX component (perhaps using ATL) and
import that into your VB app. Perhaps even rewriting the original DLL as an
ActiveX component (assuming you have the source code).

So what do you really have - a 'regular' DLL or what?

The practical difference between "ActiveX" and "COM" is just a matter of
names and context. COM is a protocol outlining a binary standard for
interprocess communication and sharing of services. The actual engine to
implement COM is OLE. Back in the old days (VB1-4(16bit)) the various
components were called "OLE" servers/containers/controls, etc. The M$
marketing started calling them "ActiveX Components".

We very seldom ever work with COM directly, instead we use various
implementations, but in general anything based on COM is called "COM". It
can get even more confusing when programmers refer to "COM+" as simply
"COM". COM+ is actually a collection of advanced COM runtime implementations
that is embedded in the OS to provide additional services.

hth
-ralph



Relevant Pages

  • byref strings c++ vb.net
    ... I'm trying to call a C++ component from my vb.net app. ... I've setup a Declare ... As String) As Integer. ... I know the DLL returns a string, but I'm unsure how to pass ...
    (microsoft.public.dotnet.languages.vb)
  • byref strings c++ vb.net
    ... I'm trying to call a C++ component from my vb.net app. ... I've setup a Declare ... As String) As Integer. ... I know the DLL returns a string, but I'm unsure how to pass ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Delphi DLL / VB app
    ... > But the real VB app ... But I quess your Delphi written ActiveX component appeared to the VB ... then VB should be aware about your DLL and ActiveX ... I use Delphi's TREGSVR.EXE for those registrations. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Loading and Unloading Unmanaged DLLs
    ... > I'm using a 3rd party DLL for operating on SNMPv3 machines. ... > But i'm coming up with a problem that when I declare a DLL ("declare ... > exit out of it it doesn't seem to be unloading the DLL (although I ... exit a VB app. ...
    (microsoft.public.vb.winapi)
  • Re: Loading and Unloading Unmanaged DLLs
    ... >I'm using a 3rd party DLL for operating on SNMPv3 machines. ... >But i'm coming up with a problem that when I declare a DLL ("declare ... VB.NET was designed by the Delphi designer ... >I've also noticed that the debug app is wrapped under the vb6.exe ...
    (microsoft.public.vb.winapi)