Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function stores a value in the calling thread's thread local storage (TLS) slot for a specified TLS index. Each thread of a process has its own slot for each TLS index.

Syntax

BOOL TlsSetValue(
  DWORD 
dwTlsIndex,
  LPVOID 
lpTlsValue
);

Parameters

dwTlsIndex

[in] Specifies a TLS index that was allocated by the TlsAllocfunction.

lpTlsValue

[in] Pointer to the value to be stored in the calling thread's TLS slot specified by dwTlsIndex.

Return Value

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

TLS indexes are typically allocated by the TlsAllocfunction during process or DLL initialization. When allocated, each thread of the process can use a TLS index to access its own TLS storage slot for that index.

The storage slot for each thread is initialized to NULL.

A thread specifies a TLS index in a call to TlsSetValueto store a value in its slot. The thread specifies the same index in a subsequent call to TlsGetValueto retrieve the stored value.

The primary goal of TlsSetValueand TlsGetValueis speed. These functions perform minimal parameter validation and error checking. In particular, this function succeeds if dwTlsIndexis in the range zero through (TLS_MINIMUM_AVAILABLE – 1). You must ensure that the index is valid.

Requirements

Header winbase.h
Library coredll.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also