Board index » cppbuilder » How to include .tlb file in project

How to include .tlb file in project

Hi,

on a Borland website and in the BCB help files I read that it's possible to
add a server's .tlb file into the project of a client, so that no additional
.tlb file has to be registered by calling tregsvr.
But how do I do that?
I wrote a .rc file like this:

1 TYPELIB "server.tlb"

and I used the BRC32.exe to compile and link it to the client's .exe file.
It didn't work.
Then I tried to add the .res file to my project - didn't work either. I
guess the OS expects the typelib to be the first resource in that file. But
I think it isn't.

Does anybody know per chance how to do that?

Thany in advance,

Sascha

 

Re:How to include .tlb file in project


Sascha,

I'm really new at this so hopefully the more seasoned veterans
will point out if I'm off base...

On the client side, you don't need the .tlb file in the
project...you need the <object name>_TLB.cpp and .h files that
were generated by the server project.  These files contain the UUID's and declarations of the exposed COM objects your client
needs.

In my experience with BCB5, the server auto-registers the COM
objects when you run it so you don't need to run TREGSVR.  I
haven't actually seen this code (I believe it is under the
covers somewhere) but I have watched the registry while
starting the server and I have seen the entries created.

If you have them, take a look and the AutoSvr and AutoCon
examples in the CBuilder directory.

Quote
"Sascha Herrmann" <Its_a_so...@t-online.de> wrote:
>Hi,

>on a Borland website and in the BCB help files I read that it's possible to
>add a server's .tlb file into the project of a client, so that no additional
>..tlb file has to be registered by calling tregsvr.
>But how do I do that?
>I wrote a .rc file like this:

>1 TYPELIB "server.tlb"

>and I used the BRC32.exe to compile and link it to the client's .exe file.
>It didn't work.
>Then I tried to add the .res file to my project - didn't work either. I
>guess the OS expects the typelib to be the first resource in that file. But
>I think it isn't.

>Does anybody know per chance how to do that?

>Thany in advance,

>Sascha

Re:How to include .tlb file in project


Hi Dave,

thanks for your answer.

Well, I do add the ...._TLB.obj (created when I compile my server) to my
project. And my client includes the ...._TLB.h file. But it seems that this
is not enough. When I start my client I get an exception (Interface
unknown), unless I register the .tlb file using tregsvr.
But you're right, the server registers the COM object - on the server
computer. But I have an out-of-process server, and my client runs on a
different computer .

But thanks anyway.

Regards,

Sascha

"Dave" <dsamp...@qwest.net> schrieb im Newsbeitrag
news:3b3b7d77$1_2@dnews...

Quote

> Sascha,

> I'm really new at this so hopefully the more seasoned veterans
> will point out if I'm off base...

> On the client side, you don't need the .tlb file in the
> project...you need the <object name>_TLB.cpp and .h files that
> were generated by the server project.  These files contain the UUID's and

declarations of the exposed COM objects your client
Quote
> needs.

> In my experience with BCB5, the server auto-registers the COM
> objects when you run it so you don't need to run TREGSVR.  I
> haven't actually seen this code (I believe it is under the
> covers somewhere) but I have watched the registry while
> starting the server and I have seen the entries created.

> If you have them, take a look and the AutoSvr and AutoCon
> examples in the CBuilder directory.

> "Sascha Herrmann" <Its_a_so...@t-online.de> wrote:
> >Hi,

> >on a Borland website and in the BCB help files I read that it's possible
to
> >add a server's .tlb file into the project of a client, so that no
additional
> >..tlb file has to be registered by calling tregsvr.
> >But how do I do that?
> >I wrote a .rc file like this:

> >1 TYPELIB "server.tlb"

> >and I used the BRC32.exe to compile and link it to the client's .exe
file.
> >It didn't work.
> >Then I tried to add the .res file to my project - didn't work either. I
> >guess the OS expects the typelib to be the first resource in that file.
But
> >I think it isn't.

> >Does anybody know per chance how to do that?

> >Thany in advance,

> >Sascha

Re:How to include .tlb file in project


Sascha,
There are two points to make:

1.  Add the xxx_TLB.cpp into your Client project, just be careful to get the
most up-to-date file. This includes all the GUID's that are needed.  This
file will include the _TLB.h file. I am assuming the client is compiled
under BCB also.

2.  Don't include the _TLB.obj to the client project because there should be
no need, and COM prevents us to be forced to link object files in any client
or compiler.

gl.....

Tom

Quote
Sascha Herrmann <Its_a_so...@t-online.de> wrote in message

news:3b3b8812_2@dnews...
Quote
> Hi Dave,

> thanks for your answer.

> Well, I do add the ...._TLB.obj (created when I compile my server) to my
> project. And my client includes the ...._TLB.h file. But it seems that
this
> is not enough. When I start my client I get an exception (Interface
> unknown), unless I register the .tlb file using tregsvr.
> But you're right, the server registers the COM object - on the server
> computer. But I have an out-of-process server, and my client runs on a
> different computer .

> But thanks anyway.

> Regards,

> Sascha

> "Dave" <dsamp...@qwest.net> schrieb im Newsbeitrag
> news:3b3b7d77$1_2@dnews...

> > Sascha,

> > I'm really new at this so hopefully the more seasoned veterans
> > will point out if I'm off base...

> > On the client side, you don't need the .tlb file in the
> > project...you need the <object name>_TLB.cpp and .h files that
> > were generated by the server project.  These files contain the UUID's
and
> declarations of the exposed COM objects your client
> > needs.

> > In my experience with BCB5, the server auto-registers the COM
> > objects when you run it so you don't need to run TREGSVR.  I
> > haven't actually seen this code (I believe it is under the
> > covers somewhere) but I have watched the registry while
> > starting the server and I have seen the entries created.

> > If you have them, take a look and the AutoSvr and AutoCon
> > examples in the CBuilder directory.

> > "Sascha Herrmann" <Its_a_so...@t-online.de> wrote:
> > >Hi,

> > >on a Borland website and in the BCB help files I read that it's
possible
> to
> > >add a server's .tlb file into the project of a client, so that no
> additional
> > >..tlb file has to be registered by calling tregsvr.
> > >But how do I do that?
> > >I wrote a .rc file like this:

> > >1 TYPELIB "server.tlb"

> > >and I used the BRC32.exe to compile and link it to the client's .exe
> file.
> > >It didn't work.
> > >Then I tried to add the .res file to my project - didn't work either. I
> > >guess the OS expects the typelib to be the first resource in that file.
> But
> > >I think it isn't.

> > >Does anybody know per chance how to do that?

> > >Thany in advance,

> > >Sascha

Re:How to include .tlb file in project


Sascha,
There are two points to make:

1.  Add the xxx_TLB.cpp into your Client project, just be careful to get the
most up-to-date file. This includes all the GUID's that are needed.  This
file will include the _TLB.h file. I am assuming the client is compiled
under BCB also.

2.  Don't include the _TLB.obj to the client project because there should be
no need, and COM prevents us to be forced to link object files in any client
or compiler.

FYI - I sent this message yesterday, don't know what happened to it.

gl.....

Tom

Quote
Sascha Herrmann <Its_a_so...@t-online.de> wrote in message

news:3b3b728d_2@dnews...
Quote
> Hi,

> on a Borland website and in the BCB help files I read that it's possible
to
> add a server's .tlb file into the project of a client, so that no
additional
> .tlb file has to be registered by calling tregsvr.
> But how do I do that?
> I wrote a .rc file like this:

> 1 TYPELIB "server.tlb"

> and I used the BRC32.exe to compile and link it to the client's .exe file.
> It didn't work.
> Then I tried to add the .res file to my project - didn't work either. I
> guess the OS expects the typelib to be the first resource in that file.
But
> I think it isn't.

> Does anybody know per chance how to do that?

> Thany in advance,

> Sascha

Re:How to include .tlb file in project


Hi Tom,

thanks for your advice.

I don't really see the difference (when I include the ..._TLB.cpp file, the
compiler will translate it into a ....TLB.obj and link it to my client, so
isn't it basically the same as using the ...TLB.obj of my server in the
first place!?!), but I will try!

Thanks again.

Regards,

Sascha

"Tom K." <tk...@socal.rr.com> schrieb im Newsbeitrag
news:3b3ca68a$1_2@dnews...

Quote
> Sascha,
> There are two points to make:

> 1.  Add the xxx_TLB.cpp into your Client project, just be careful to get
the
> most up-to-date file. This includes all the GUID's that are needed.  This
> file will include the _TLB.h file. I am assuming the client is compiled
> under BCB also.

> 2.  Don't include the _TLB.obj to the client project because there should
be
> no need, and COM prevents us to be forced to link object files in any
client
> or compiler.

> FYI - I sent this message yesterday, don't know what happened to it.

> gl.....

> Tom

> Sascha Herrmann <Its_a_so...@t-online.de> wrote in message
> news:3b3b728d_2@dnews...
> > Hi,

> > on a Borland website and in the BCB help files I read that it's possible
> to
> > add a server's .tlb file into the project of a client, so that no
> additional
> > .tlb file has to be registered by calling tregsvr.
> > But how do I do that?
> > I wrote a .rc file like this:

> > 1 TYPELIB "server.tlb"

> > and I used the BRC32.exe to compile and link it to the client's .exe
file.
> > It didn't work.
> > Then I tried to add the .res file to my project - didn't work either. I
> > guess the OS expects the typelib to be the first resource in that file.
> But
> > I think it isn't.

> > Does anybody know per chance how to do that?

> > Thany in advance,

> > Sascha

Other Threads