Udostępnij za pośrednictwem


ISupportErrorInfoImpl Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at ISupportErrorInfoImpl Class.

This class provides a default implementation of the ISupportErrorInfo Interface and can be used when only a single interface generates errors on an object.

Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

Syntax

template<const IID* piid>  
class ATL_NO_VTABLE ISupportErrorInfoImpl 
   : public ISupportErrorInfo

Parameters

piid
A pointer to the IID of an interface that supports IErrorInfo.

Members

Public Methods

Name Description
ISupportErrorInfoImpl::InterfaceSupportsErrorInfo Indicates whether the interface identified by riid supports the IErrorInfo interface.

Remarks

The ISupportErrorInfo Interface ensures that error information can be returned to the client. Objects that use IErrorInfo must implement ISupportErrorInfo.

Class ISupportErrorInfoImpl provides a default implementation of ISupportErrorInfo and can be used when only a single interface generates errors on an object. For example:

class ATL_NO_VTABLE CMySuppErrClass :
   public CComObjectRootEx<CComSingleThreadModel>,
   public CComCoClass<CMySuppErrClass, &CLSID_MySuppErrClass>,
   public ISupportErrorInfoImpl<&IID_IMySuppErrClass>,
   public IDispatchImpl<IMySuppErrClass, &IID_IMySuppErrClass, &LIBID_NVC_ATL_COMLib, /*wMajor =*/ 1, /*wMinor =*/ 0>

Inheritance Hierarchy

ISupportErrorInfo

ISupportErrorInfoImpl

Requirements

Header: atlcom.h

ISupportErrorInfoImpl::InterfaceSupportsErrorInfo

Indicates whether the interface identified by riid supports the IErrorInfo interface.

STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

Remarks

See ISupportErrorInfo::InterfaceSupportsErrorInfo in the Windows SDK.

IThreadPoolConfig::GetSize

Call this method to get the number of threads in the pool.

STDMETHOD(GetSize)(int* pnNumThreads);

Parameters

pnNumThreads
[out] Address of the variable that, on success, receives the number of threads in the pool.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Example

HRESULT DoPoolOperations(IThreadPoolConfig* pPool, int nSize)
{
    int nCurrSize = 0;
    HRESULT hr = pPool->GetSize(&nCurrSize);
    if (SUCCEEDED(hr))
    {
        printf_s("Current pool size: %d\n", nCurrSize);
        hr = pPool->SetSize(nSize);
        if (SUCCEEDED(hr))
        {
            printf_s("New pool size : %d\n", nSize);
            DWORD dwTimeout = 0;
            hr = pPool->GetTimeout(&dwTimeout);
            if (SUCCEEDED(hr))
            {
                printf_s("Current pool timeout: %u\n", dwTimeout);
                // Increase timeout by 10 seconds.
                dwTimeout += 10 * 1000;
                hr = pPool->SetTimeout(dwTimeout);
                if (SUCCEEDED(hr))
                {
                    printf_s("New pool timeout: %u\n", dwTimeout);
                }
                else
                {
                    printf_s("Failed to set pool timeout: 0x%08X\n", hr);
                }
            }
            else
            {
                printf_s("Failed to get pool timeout: 0x%08X\n", hr);
            }
        }
        else
        {
            printf_s("Failed to resize pool: 0x%08X\n", hr);
        }
    }
    else
    {
        printf_s("Failed to get pool size: 0x%08x\n", hr);
    }

    return hr;
}

IThreadPoolConfig::GetTimeout

Call this method to get the maximum time in milliseconds that the thread pool will wait for a thread to shut down.

STDMETHOD(GetTimeout)(DWORD* pdwMaxWait);

Parameters

pdwMaxWait
[out] Address of the variable that, on success, receives the maximum time in milliseconds that the thread pool will wait for a thread to shut down.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Example

See IThreadPoolConfig::GetSize.

IThreadPoolConfig::SetSize

Call this method to set the number of threads in the pool.

STDMETHOD(SetSize)(int nNumThreads);

Parameters

nNumThreads
The requested number of threads in the pool.

If nNumThreads is negative, its absolute value will be multiplied by the number of processors in the machine to get the total number of threads.

If nNumThreads is zero, ATLS_DEFAULT_THREADSPERPROC will be multiplied by the number of processors in the machine to get the total number of threads.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Example

See IThreadPoolConfig::GetSize.

IThreadPoolConfig::SetTimeout

Call this method to set the maximum time in milliseconds that the thread pool will wait for a thread to shut down.

STDMETHOD(SetTimeout)(DWORD dwMaxWait);

Parameters

dwMaxWait
The requested maximum time in milliseconds that the thread pool will wait for a thread to shut down.

Return Value

Returns S_OK on success, or an error HRESULT on failure.

Example

See IThreadPoolConfig::GetSize.

See Also

Class Overview