When you write an IDL file and need to add specific C++ code in the header file created after MIDL compilation, you can use the the cpp_quote(” “) IDL construct. For example:
import "unknwn.idl"cpp_quote(" //This will go to header file")cpp_quote(" #ifdef _MYLIBSEARCH ")cpp_quote(" #pragma comment(lib,"uuid.lib")")cpp_quote(" #endif")interface IX : IUnknown{ ...}
Before the age of COM, projects generally had main and common header files for the entire project. Now there are shareable IDL files for many projects, but the language for the project is still C++. This is a convenient way to sync all the users of an IDL file for a correct header file generation.