Board index » delphi » Usind Delphi created COM object in VC++

Usind Delphi created COM object in VC++

Hi all,
I've created a COM dll using Delphi, what are the steps necessary to use
this object in plain VC++ code (sans MFC and ATL)? I understood that I need
to use the import keyword to load the TLB from the dll, then specign that I
want to use that name space with 'using namespace DelphiObj' but then what I
need to create and istance of the object itself and call the method using
what VC calls smartpointers?

Thanx,
lev

 

Re:Usind Delphi created COM object in VC++


Let's say you create a server named FooServer, a coclass named Foo, and a
default interface named IFoo that contains 1 method Bar.

After you #import it into VC++:

using namespace FooServer;

void TestFoo ()
{
    IFooPtr AFoo (__uuidof (Foo));
    AFoo->Bar ();

Quote
}

--
have fun

Binh Ly
www.techvanguards.com

Quote
"Emanuele Cipolloni" <emanu...@hillsdon.com> wrote in message

news:3acf771b_2@dnews...
Quote
> Hi all,
> I've created a COM dll using Delphi, what are the steps necessary to use
> this object in plain VC++ code (sans MFC and ATL)? I understood that I
need
> to use the import keyword to load the TLB from the dll, then specign that
I
> want to use that name space with 'using namespace DelphiObj' but then what
I
> need to create and istance of the object itself and call the method using
> what VC calls smartpointers?

> Thanx,
> lev

Re:Usind Delphi created COM object in VC++


Binh,
I'm trying to do the same thing with a BCB 5 COM object.  When I try to do
as you show below, VC++ says IFooPtr and Foo are undeclared identifiers in
the line that has __uuidof (I'm using your server names, mine are
considerably different, but still apply).  My import looks like:
#import "FooServer.exe"
Should I use no_namespace, or "Foo" or what?  Or should I include the IDL in
the project(instead?  In addition?)  I checked your web site, but couldn't
find VC++ specifics (which shows you are a sane person, I suppose<g>).
This is SOOO much easier in VB!
Dave
Quote
Binh Ly wrote in message <3acf8d08_2@dnews>...
>Let's say you create a server named FooServer, a coclass named Foo, and a
>default interface named IFoo that contains 1 method Bar.

>After you #import it into VC++:

>using namespace FooServer;

>void TestFoo ()
>{
>    IFooPtr AFoo (__uuidof (Foo));
>    AFoo->Bar ();
>}

Other Threads