Re: Importing classes from Dll

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Igor Tandetnik (itandetnik_at_mvps.org)
Date: 04/02/04


Date: Fri, 2 Apr 2004 09:41:14 -0500


"Hari" <anonymous@discussions.microsoft.com> wrote in message
news:7109A866-0A64-477A-AB45-0494E1B2E8EF@microsoft.com
> Thanks for your reply.. still i have one doubt, by having an abstact
> class how it will work still everythinng is in the DLL right. I think
> u must be laughing. but still not clear

You see, an interface is not much more than an array of function
pointers (aka vtable). So you ask your factory function (GetObj in your
example) to provide a pointer to an array of function pointers, which
happen to point to methods of a particular class that implements the
interface. These methods are inside the DLL. Whenever you call a method
through interface pointer, the compiler calls through function pointer
in the vtable.

So in the end, there's no black magic. You could do the same thing
yourself. But the compiler neatly isolates the boring and tedious parts,
adding a syntactic sugar on top via the concept of virtual function.

-- 
With best wishes,
    Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Relevant Pages

  • Re: C# DLL mittels COM-Interop aus C aufrufen
    ... Have u tried the IDispatch interface, which is used for those language ... which doesnot have capability of maintaining VTables. ... The __cplusplus symbol is defined automatically when you're compiling C ... appropriate function pointer type. ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: Pointers in derived types, help needed
    ... subroutine/function must have an explicit interface. ... C is not a pointer. ... then probably the best thing to do is use allocatables. ...
    (comp.lang.fortran)
  • Re: Why ABCs make bad Interfaces
    ... > equivalent to an Abstract Base Class (ABC). ... > because it is common practice to implement an interface using ABC's. ... To convert an object to its interface, you return a fat pointer ... The NaiveInt constructor has to set up the vtables, ...
    (comp.object)
  • Re: another COM-Question: how to inject a type-lib into a dll?
    ... > But let me ask just another question on this: If this pointer is ... This is why the object exposes the COM interface in the first ... Make sure SomeObject has a reference count of 1 at this point. ... The declaraion of SomeOtherCOMMethod has a different signature. ...
    (microsoft.public.vc.atl)
  • Re: Stupid tcl/tcom newbie question
    ... Pointer to variant in tcom ... Excel's COM interface does not appear to have any methods ... So I can't test my code on Excel. ... Sub Load DLLComp() ...
    (comp.lang.tcl)