Click or drag to resize

VPrintf

Sends formatted output to a device.

virtual HRESULT VPrintf(const CString strFormat, va_list& argList, long lTimeout = CUR_TIMEOUT) abstract;	
Parameters
strFormat

[in] String describing the format for arguments. See the topic I/O Format Specifiers for Write Operations for details.

argList

[in] Argument list interpreted by the format string.

lTimeout

[in] I/O timeout in milliseconds.

Return Value

Returns S_OK if successful, otherwise a failure HRESULT.

Remarks

This function behaves identically to Printf except that the argument list is supplied using a va_list argument list instead of separate argument parameters. This type of argument list function is typically used to implement higher-level functions that accept variable argument lists. Indeed, the implementation of Printf in NtlIo.inl is done in terms of VPrintf, as shown in the example later.

The lTimeout parameter allows the I/O timeout to be temporarily changed to the specified value for the duration of the VPrintf function call. The timeout is returned to its previous value after VPrintf returns. If lTimeout is not specified, then the I/O timeout is not modified.

Example

The following example demonstrates use of the VPrintf function.

C++
// NtlIo.inl
inline HRESULT CIoSession::Printf(const CString strFormat, ...)
{
    HRESULT hr = S_OK;

    va_list argList;
    va_start(argList, strFormat);

    hr = CFormattedIo::VPrintf(m_spBuf, m_pEnumFormatter, strFormat, argList);

    va_end(argList);

    if (SUCCEEDED(hr))
    {
        hr = PollInstrumentErrors();
    }

    return hr;
}
See Also

Other Resources

Download a complete CHM version of this documentation here.