usesgetlasterror attribute

The [usesgetlasterror] attribute signals the caller that it can call GetLastError to retrieve the error code.

[
    module-attributes
]
module module-name
{
    [entry(entry-id), usesgetlasterror [, other-attributes]] return-type function-name(param-list);
};

Parameters

module-attributes

Zero or more MIDL attributes that will be applied to the module.

module-name

The identifier name of the module.

entry-id

Specifies the module entry point–function name or integer-identification number.

other-attributes

Zero or more MIDL attributes that will be applied to the remote procedure.

return-type

The type of the data that the remote procedure will return upon completion.

function-name

The name of the remote procedure as defined in the IDL file.

param-list

Zero or more parameters to the remote procedure.

Remarks

The [usesgetlasterror] attribute can be set on a module entry point, if that entry point uses the Windows function SetLastError to return error codes. The attribute tells the caller that, if there is an error when calling that function, the caller can then call GetLastError to retrieve the error code.

Examples

[
    dllname("MyOwn.dll")
] 
module MyModule
{
    [entry("One"), usesgetlasterror, bindable, requestedit,
     propputref, defaultbind] HRESULT Func1(
         [in]IUnknown * iParam1, 
         [out] long * Param2) ;
    [entry("TwentyOne"), usesgetlasterror, 
     hidden, vararg] SAFEARRAY (int) Func2(
         [in, out] SAFEARRAY (variant) *varP) ;

    // Other module definition statements.
};

See also

Generating a Type Library With MIDL

ODL File Example

ODL File Syntax