1

I'm making a COM interface, ITest which is part of a test suite running only in a local process. The particular functionality I'm testing is not important but the main point is I will not be using CoCreateInstance() or any factory objects to instantiate the backing object and get a pointer to the interface. I will simply call a trivial function that looks like this:

HRESULT InstantiateTestObject(ITest ** pptest);

Obviously, I only need a fairly minimal subset of the whole functionality provided by COM.

With that in mind, here's my question.

I understand you can use nul as a way of telling midl not to generate a particular file (e.g.midl itest.idl /iid nul to suppress generating the IID file). If I only plan to instantiate the object backing my ITest interface via the trivial function shown above, and I only plan to use it in the local process, what is the smallest subset of midl output files I actually need?

0xbe5077ed
  • 4,565
  • 6
  • 35
  • 77
  • If you don't need cross-apartment marshaling, then you don't need an IDL file at all. Just define your interface in an .h file. – Igor Tandetnik Oct 20 '13 at 23:27
  • The reason I'm using an IDL file (maybe I'm wrong here?) is `ITest` is actually an `IDispatch`-supporting dual interface (*i.e.* `[dual, local, ...] interface ITest : IDispatch`) and I want `midl` to generate the TLB file which I need to simplify my implementation of `IDispatch`. Does this make sense? – 0xbe5077ed Oct 20 '13 at 23:31
  • 1
    Well, then yes, you would want an IDL definition. If I recall correctly, if you put your interface definition inside the `library{}` block, then MIDL won't generate *_i.{h,c} files - only the TLB file and the .h file with the interface definition. – Igor Tandetnik Oct 20 '13 at 23:39
  • That actually worked perfectly for my purposes. I put my interface inside the `library` block and it spat out only the TLB. If you run it with the /h switch it will also generate the header. Thanks! Do you want to put your comment in an answer? If so I'll accept it. – 0xbe5077ed Oct 20 '13 at 23:48

0 Answers0