Re: DLL Vs. COM

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: David Mair (mairdanot_at_nothotmail.com)
Date: 07/04/04


Date: Sun, 04 Jul 2004 11:45:45 -0600

Vengidi wrote:

> Hi,
> I have a nagging question now. When I can reuse features with exported
> functions from a DLL, then why COM ? How does COM Outweigh a simple dll in
> this regard ?

I would guess at interface consistency (standardised interfaces like
IMalloc for example). This allows for things that are different to
appear to be the same, or appear to have some aspects that are the same.
  A perfect example from my own work is that all video sources that are
DirectShow compatible can be handled using the same code (this includes,
TV tuners, capture cards, webcams, etc). Common interfaces only need to
be published in one header file (often in Microsoft SDKs) whereas
multiple DLLs, even if using the same interfaces would have to publish
their own class definitions, especially if they came from different
vendors. One thing I'm not certain about but I think is the case is
that a class declaration would have to publish the internal interfaces
as well as the external ones in order for a C++ compiler to be able to
use it. With COM the exposed interfaces don't need to indicate anything
about implementation. COM also supports interfaces with other processes
(the shell, for example). In the case of the shell I can be the DLL
running in the shell's address space, as in the case of a shell
extension (e.g. context menu handler) and I don't have to tell the shell
what my interface is because it is a standard and the shell doesn't need
to be re-compiled in order to use my DLL. The same goes for custom
controls, they can be used in another application without that
application habing to know anything about them. The use of unique
identity that is external to the source that uses COM objects is another
nice detail in the implementation of COM. You can iterate the set of
installed COM objects and create instances of them without having to
re-compile or know much about them (at best just the interfaces they
implement: IUnknown::QueryInterface() IIRC).

COM can be very complicated to use, it took me a lot of research and
testing to write a webcam app with Windows Media video capture but the
nice thing is that it should be portable through at least several
iterations of DirectShow (support multiple video sources including some
that don't yet exist) and Windows Media without the need for me to
re-compile. Source using COM can be ugly to look at but I find it to be
very powerful (two of the things I like most about Windows programming
are UI messages and COM so I guess I'm biased).

For the conspiracy theorists it was just a way to offset the potential
effect of CORBA but even if that was true it has developed in a rather
impressive manner.



Relevant Pages

  • Re: QueryInterface failure.
    ... Not sure what you mean by a DLL desribing all interfaces. ... Microsoft MVP, MCSD ... Compile the common IDL file that containing all the shared interfaces ...
    (microsoft.public.vc.atl)
  • Re: Using Labview 8 with MS Visual Studio .net 2003 to create .lsb file
    ... You say that you would get problems when using your C++ interfaces from ... a DLL due to compiler differences. ... you have only one DLL to create instead of many CIN code resources. ... interfacing to the different DLLs/shared libraries on all the different ...
    (comp.lang.labview)
  • Re: WCF Advice
    ... I would definitely have the data types and the contracts in one dll. ... The service and the client would share the dll that has the interfaces and data structures that are passed between client and service. ... If you are publishing your metadata through Metadata Exchange, then you can have VS.NET connect to your service and create the proxy and all data types needed automatically. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Öh sieht schon wieder besser aus , was ?
    ... dass die Typelib als Ressource in die ... > die TypeLib ist aber nicht mit dabei, habe nur die DLL bei AS gefunden ... könnte auch der Viewer nichts über die Interfaces aussagen. ... Die Objekte unterstützen IDispatch, dann kannst du die ...
    (microsoft.public.de.vc)
  • Re: Can an application blue-screen Windows 2000/XP?
    ... The Default Shell has some responsabilities that NtUser is aware of. ... The app is running on touch-screen information-booth type PCs. ... To the best of my knowledge the DLL is merely ... Internet Explorer be involved in causing a bugcheck or is that still ...
    (microsoft.public.win32.programmer.kernel)