Generate tlh/tli from a tlb?

S

Skirmish

Long story short: I've been able to load a C# dll in C++ by having the
C# project generating a type library (tlb) and #importing that in C+
+. The #import directive looks like a compiler shortcut that
generates a tlh and tli locally. Now what I want to be able to do is
generate the tlh and tli somehow and include them directly in my C++
project, thus doing away with the need for the #import statement.

I've looked at the MIDL.exe help but couldn't see a way to do this. I
also tried using a new C++ project that simply #imports the tlb with
the hope that I could specify where the tlh and tli get generated, but
I couldn't see a setting for that.

Any help would be appreciated.

Cheers
Adam Bryant
 
C

Carl Daniel [VC++ MVP]

Skirmish said:
Long story short: I've been able to load a C# dll in C++ by having the
C# project generating a type library (tlb) and #importing that in C+
+. The #import directive looks like a compiler shortcut that
generates a tlh and tli locally. Now what I want to be able to do is
generate the tlh and tli somehow and include them directly in my C++
project, thus doing away with the need for the #import statement.

I've looked at the MIDL.exe help but couldn't see a way to do this. I
also tried using a new C++ project that simply #imports the tlb with
the hope that I could specify where the tlh and tli get generated, but
I couldn't see a setting for that.

You've pretty much summed up the situation: #import is a compiler tool that
builds a .tlh/.tli from a .tlb and there's no way to specify where the
resulting files should be placed. The best you can do is to create a simple
C++ project that #imports your .tlb and then copy the .tlh/.tli from the
"intermediate files" directory of the project (typically %PROJECTDIR%\Debug
or %PROJECTDIR%\Release) to a common include directory.

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top