interface interface-name
{
return-type func-name(mandatory-param-list,
[[attribute-list,] defaultvalue(value)] param-type param-name[, optional-param-list]);
}
interface IFoo : IUnknown
{
HRESULT Ex1([defaultvalue(44)] LONG i);
HRESULT Ex2([defaultvalue(44)] SHORT i);
HRESULT Ex3([defaultvalue("Hello")] BSTR i);
...
}
interface QueryDef : IUnknown
{
HRESULT OpenRecordset( [in, defaultvalue(DBOPENTABLE)]
LONG Type,
[out,retval] Recordset **pprst);
}
// Type is now known to be a LONG type (good for browser in VBA and
// good for a C/C++ programmer) and has a default value of
// DBOPENTABLE
The defaultvalue attribute allows specification of a default value for a typed optional parameter. The value can be any constant, or an expression that resolves to a constant, that can be represented by a VARIANT. Specifically, you cannot apply the defaultvalue attribute to a parameter that is a structure, an array, or a SAFEARRAY.type.
The MIDL compiler accepts the following parameter ordering (from left-to-right):
interface, dispinterface, TYPEFLAGS, ODL File Syntax, ODL File Example, Generating a Type Library With MIDL