IBackgroundCopyManager::GetErrorDescription method (bits.h)

Retrieves a description for the specified error code.

Syntax

HRESULT GetErrorDescription(
  [in]  HRESULT hResult,
  [in]  DWORD   LanguageId,
  [out] LPWSTR  *pErrorDescription
);

Parameters

[in] hResult

Error code from a previous call to a BITS method.

[in] LanguageId

Identifies the language identifier to use to generate the description. To create the language identifier, use the MAKELANGID macro. For example, to specify U.S. English, use the following code sample.

MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)

To retrieve the system's default user language identifier, use the following calls.

LANGIDFROMLCID(GetThreadLocale())

[out] pErrorDescription

Null-terminated string that contains a description of the error. Call the CoTaskMemFree function to free ppErrorDescription when done.

Return value

This method returns the following HRESULT values, as well as others.

Return code Description
S_OK
Error code description was successfully retrieved.
HRESULT_FROM_WIN32(ERROR_RESOURCE_LANG_NOT_FOUND)
No string is available for the locale.

Remarks

Descriptions for HTTP errors are localized.

Windows XP/2000:  Descriptions for HTTP errors are not localized.

Examples

The following example shows how to retrieve the description associated with an error code. The g_XferManager variable in the example is an IBackgroundCopyManager interface pointer. For details on creating the IBackgroundCopyManager interface pointer, see Connecting to the BITS Service.

HRESULT hr = 0;
IBackgroundCopyJob* pJob = NULL;
WCHAR* pszDescription = NULL;

//Call fails because the third parameter is NULL.
hr = g_XferManager->CreateJob(L"DummyJob", BG_JOB_TYPE_DOWNLOAD, NULL, &pJob);
if (FAILED(hr))
{
  hr = g_XferManager->GetErrorDescription(hr, LANGIDFROMLCID(GetThreadLocale()), &pszDescription);
  if (SUCCEEDED(hr))
  {
    //Do something with pszDescription.
    CoTaskMemFree(pszDescription);
  }
}

Requirements

Requirement Value
Minimum supported client Windows XP
Minimum supported server Windows Server 2003
Target Platform Windows
Header bits.h
Library Bits.lib
DLL QmgrPrxy.dll

See also

Handling Errors

IBackgroundCopyError

IBackgroundCopyJob::GetError