GetThreadDescription function (processthreadsapi.h)

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


HRESULT GetThreadDescription(
  [in]  HANDLE hThread,
  [out] PWSTR  *ppszThreadDescription


[in] hThread

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

[out] 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.


Windows Server 2016, Windows 10 LTSB 2016 and Windows 10 version 1607: GetThreadDescription is only available by Run Time Dynamic Linking in KernelBase.dll.

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.


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\n”, data);


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