GetThreadDescription function

Retrieves the description that was assigned to a thread by calling SetThreadDescription.

Syntax

HRESULT GetThreadDescription(
  HANDLE hThread,
  PWSTR  *ppszThreadDescription
);

Parameters

hThread

A handle to the thread for which to retrieve the description. The handle must have THREAD_QUERY_LIMITED_INFORMATION access.

ppszThreadDescription

A Unicode string that contains the description of the thread.

Return Value

If the function succeeds, the return value is the HRESULT that denotes a successful operation. If the function fails, the return value is an HRESULT that denotes the error.

Remarks

The description for a thread can change at any time. For example, a different thread can change the description of a thread of interest while you try to retrieve that description.

Thread descriptions do not need to be unique.

To free the memory for the thread description, call the LocalFree method.

Examples

The following example gets the description for a thread, prints the description, and then frees the memory for the description.

HRESULT hr = GetThreadDescription(ThreadHandle, &data);
if (SUCCEEDED(hr))
{   
    wprintf(“%ls\m”, data);
    LocalFree(data);
}

Requirements

   
Minimum supported client Windows 10, version 1607 [desktop apps | UWP apps]
Minimum supported server Windows Server 2016 [desktop apps | UWP apps]
Target Platform Windows
Header processthreadsapi.h
Library Kernel32.lib
DLL Kernel32.dll

See Also

LocalFree

SetThreadDescription