• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 981
  • Last Modified:

Modifying a tli file

I use #import to import a COM server interface.
The compiler automatically generates the tli and tlh files.
Up to here, all is ok.

But now i need to add code in the methods present in the tli.
And this i dont know how to do that.

So :
Is it possible to directly import a tli and tlh file without the compiler to rebuild it each time the stdafx is build ?

  • 3
  • 2
1 Solution
1. Methods in tli file are proxy methods which call COM component methods. tli and tlh file are build by COM library from #import directive. Changes should be done in COM library and not in tli file. Files generated by compiler should not be edited manually.

2. You can use Class Wizard, Add Class, From Type Library function. COM wrapper class made by such way is generated only once. But if COM library interface is changed, you must generate this class again.

I suggest you to use #import, this is better. There was discussion here in EE about #inport vs. COM wrapper. #import is better.
eric3333Author Commented:
I do not want to change the COM server.
I want to add code in the tli file.

So my question was : Is it posisble to change a tli file and to order the compiler to NOT reimport the COM server but to use the modified tli file ?

So is this possible ?
eric3333Author Commented:
Another point.

My needs is to be able to add a line of code EACH time a method of the smart pointer (TLI methods) are called.
Perhaps it could be possible to change the based smartpointer method.

But how to do that ?
I think this is better to do in your code - just add your own wrapper.
If you want to modify tli/tlh file, you can do this, and after this remove #import directive and include generated files to your code directly. I have never do this, but this is the meaning of #import directive.
Again, I recommend you to write your wrapper which imports library and adds your own code.
eric3333Author Commented:
So simple.
I just remove the #import
Add a #include of the tlh in the precompiled header
Add the tli in the project
It works and i can change the tli


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now