次の方法で共有


AMGetErrorText

 
Microsoft DirectShow 9.0

AMGetErrorText

The AMGetErrorText function retrieves the error message for a given return code, using the current language setting.

This function converts HRESULT return codes to error messages. The constant MAX_ERROR_TEXT_LEN specifies the maximum number of characters in an error message.

Syntax

  DWORD AMGetErrorText(
    HRESULT hr,
    TCHAR* pBuffer,
    DWORD MaxLen
);

Parameters

hr

HRESULT value.

pBuffer

Pointer to a character buffer that receives the error message.

MaxLen

Number of characters in pBuffer.

Return Value

Returns the number of characters returned in the buffer, or zero if an error occurred.

Remarks

The DirectX SDK also provides the DXGetErrorString9 function, which returns error strings for all of the DirectX components, including DirectShow, plus standard Win32 errors.

Example Code

void ShowError(HRESULT hr)
{
    if (FAILED(hr))
    {
        TCHAR szErr[MAX_ERROR_TEXT_LEN];
        DWORD res = AMGetErrorText(hr, szErr, MAX_ERROR_TEXT_LEN);
        if (res == 0)
        {
            StringCchPrintf(szErr, MAX_ERROR_TEXT_LEN, "Unknown Error: 0x%2x", hr);
        }
        MessageBox(0, szErr, TEXT("Error!"), MB_OK | MB_ICONERROR);
    }
}

Requirements

Header: Dshow.h.

Library: Link to the library file Quartz.lib.

See Also