0
votes

the .exe of the application allows to dump IDL-definitions to a .IDL file.

with midl I can create a .tlb file.

But in C-compiler with the #import statement I got the error cannot open source file ... .tlh

How to fix it?

In VS Visual Basic project I'm able to use this application with the COM-Interface, but have other troubles with.

Thank you for advice Erhy

1
#include requires C++. Don't be misled by the IntelliSense parser, it will complain about a missing .tlh file at first. Use Build > Build to ensure the .tlh file is generated.Hans Passant

1 Answers

0
votes

I done it like as Kim Gräsman advised in https://stackoverflow.com/a/1854637/3127177

Here my way for the application TheServerApp :

all with installed Microsoft Visual Studio Community 2017

with command line

Search and execute vcvars32.bat

then execute

oleview

(if it makes problem the first time oleview.exe has to been executed as administrator)

in oleview window choose View TypeLibs

and open TheServerApp.exe

and then File -> Save As

So the IDL definitions are stored in TheServerApp.idl

cd where TheServerApp.IDL is located

and execute

midl TheServerApp.IDL

because I got the errors

TheServerApp.IDL(481) : error MIDL2025 : syntax error : expecting a type specification near "single"

Client\TheServerApp.IDL(481) : error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation

I edited TheServerApp.IDL and replaced all words single with double

( see here )

Now the execution of midl TheServerApp**.IDL**

results in the file TheServerApp**.tlb**

because #import TheServerApp.tlb in the Visual Studio project reports an error

write a small program imports.cpp in your project with the content:

// file to import with full path
**#import** " ... /**TheServerApp.tlb**"
int main(int argc, char* argv[])
{
}

and in Command Line with executed vcvars32.bat as above

execute cl ./imports.cpp

which generates TheServerApp**.tlh** and TheServerApp**.tli**

in .cpp I included

#include "./TheServerApp.tlh"
#include "./TheServerApp.tli"

I generated also TheServerApp.dll, but don't know it will be needed further

tlbimp TheServerApp.tlb

which reports

TlbImp : Type library imported to TheServerApp.dll

so there is also the file TheServerApp.dll

for the next steps I have to study more

Erhy