Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Assigns a description to a thread.
Syntax
HRESULT SetThreadDescription(
  [in] HANDLE hThread,
  [in] PCWSTR lpThreadDescription
);
Parameters
[in] hThread
A handle for the thread for which you want to set the description. The handle must have THREAD_SET_LIMITED_INFORMATION access.
[in] lpThreadDescription
A Unicode string that specifies 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 of a thread can be set more than once; the most recently set value is used. You can retrieve the description of a thread by calling GetThreadDescription.
Windows Server 2016, Windows 10 LTSB 2016 and Windows 10 version 1607: SetThreadDescription is only available by Run Time Dynamic Linking in KernelBase.dll.
Examples
The following example sets the description for the current thread to simulation_thread.
HRESULT hr = SetThreadDescription(GetCurrentThread(), L"simulation_thread");
if (FAILED(hr))
{
    // Call failed.
}
Requirements
| Requirement | Value | 
|---|---|
| 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
GetThreadDescription, How to: Set a Thread Name in Native Code