Re: Class export by regular DLL (vc++) be used in vb
From: Ralph (msnews.20.nt_consulting32_at_spamgourmet.com)
Date: 12/07/04
- Next message: Frank Adam: "Re: RichTextBox changing properties"
- Previous message: Dan: "Re: Window display mystery"
- In reply to: polybear: "Class export by regular DLL (vc++) be used in vb"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Frank Adam: "Re: RichTextBox changing properties"
- Previous message: Dan: "Re: Window display mystery"
- In reply to: polybear: "Class export by regular DLL (vc++) be used in vb"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|