defaultvalue
interface
interface-name
{
return-type
func-name(mandatory-param-list,
[[attribute-list,] defaultvalue(value)] param-type
param-name[, optional-param-list]);
}
Examples
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
Remarks
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):
1. Required parameters (parameters that do not
have the defaultvalue or optional attributes),
2. optional parameters with or without the defaultvalue
attribute,
3. parameters with the optional attribute and without the defaultvalue
attribute,
4. lcid parameter, if any,
5. retval parameter
See Also