Question

My question is: what is the correct usage of the version tag in an IDL file that defines COM interfaces and classes and enums?

The MSN documentation of it is confusing: the first paragraph under "Remarks" seems to clearly say that the IID must be changed if anything changes in the interface.

But the rest of the page goes on to describe using differing versions with the same IID. There is even one of the sample COM interface pages that shows using version with interface.

What's going on?

Additional question: is it permitted to use version with an enum ? MIDL 7.00.05555 accepts the version attribute for enum, however if a versioned enum is used as a function parameter, MIDL gives an error.

Was it helpful?

Solution

[version] attribute applies to DCE-RPC interfaces, not to COM interfaces (MIDL compiler supports both). Witness two quotes from the first article you cite:

The [version] interface attribute identifies a particular version among multiple versions of an RPC interface. (emphasis mine)

The MIDL compiler does not support multiple versions of a COM interface. As a result, an interface attribute list that includes the [object] attribute cannot include the [version] attribute.

In COM programming, the only useful place you could apply a [version] attribute is on a library clause. Type libraries support versioning.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top