0
votes

If I use the OLE/COM Object Viewer (oleview.exe) from Visual Studio (2015) to display (generate) IDL from the Excel executable (from MSO 2007), I see that lots of methods in lots of interfaces have an LCID parameter.

For instance, the Volatile() method of the _Application interface. The oleview-generated IDL looks like:

HRESULT Volatile([in, optional] VARIANT Volatile, 
                 [in, lcid] long lcid);

(Also, how can an optional parameter be followed by non-optional ones?)

If I use the Win32 API (LoadTypeLibEx(), ITypeLib, ITypeInfo, etc) to inspect the same Excel executable as a type library, I don't see such parameters at all. If I were to generate a corresponding C++ declaration based on what ITypeInfo methods tell me, it would be just:

HRESULT Volatile(VARIANT Volatile);

I have not seen corresponding weirdness in the Word type library (which isn't inside the Word executable, but in a separate msword.olb file). At least not for those interfaces in it that one comes across right from the start when investigating this stuff, i.e. _Application and Document.

What is going on?

1
I see it. You found a bug in oleview.exe.Hans Passant

1 Answers

0
votes

I got it: What I am seeing is caused by the fact that the _Application interface is a so-called dual interface. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms686592(v=vs.85).aspx . Its TYPEATTR has the TYPEFLAG_FDUAL bit set in its wTypeFlags.

This means that there is a corresponding "vtable-based" interface, the ITypeInfo of which you can get by calling GetRefTypeOfImplType(-1) and then GetRefTypeInfo() on the returned HREFTYPE. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms221569(v=vs.85).aspx . This is the interface that oleview is displaying in its generated IDL.

In this vtable-based interface, the Volatile() method does have that LCID parameter. (Presumably, in the PARAMDESC for that parameter, the wParamFlags will have PARAMFLAG_FLCID set, haven't yet verified that.)

The same presumably holds for all other similar methods that are shown to have a LCID parameter in the oleview-generated IDL. There are also some other differences between the type information for the vtable-based interface, related to how the return value is presented, and the order in which parameters are listed. I haven't yet checked whether there can be more, like even more substantial differences in types and numbers of parameters between the IDispatch- and vtable-based interfaces of dual interface.