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. |
This function retrieves the 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.
LPVOID TlsGetValue( DWORD dwTlsIndex );
Parameters
Return Values
The value stored in the calling thread's TLS slot associated with the specified index indicates success. Zero indicates failure. To get extended error information, call GetLastError.
The data stored in a TLS slot can have a value of zero. In this case, the return value is zero and GetLastErrorreturns NO_ERROR.
Remarks
TLS indexes are typically allocated by the TlsAllocfunction during process or DLL initialization. Once 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 TlsSetValue, to store a value in its slot. The thread specifies the same index in a subsequent call to TlsGetValue, to retrieve the stored value.
For Windows CE version 3.0 and later, NULL is returned when TlsGetValueis called before TlsSetValue. For Windows CE versions 1.0 through 2.12, the returned value is not guaranteed to be NULL.
TlsSetValueand TlsGetValuewere implemented with speed as the primary goal. These functions perform minimal parameter validation and error checking. In particular, this function succeeds if dwTlsIndexis in the range 0 through (TLS_MINIMUM_AVAILABLE – 1). It is up to the programmer to ensure that the index is valid.
Win32 functions that return indications of failure call SetLastErrorwhen they fail. They generally do not call SetLastErrorwhen they succeed. The TlsGetValuefunction is an exception to this general rule. The TlsGetValuefunction calls SetLastErrorto clear a thread's last error when it succeeds. That allows checking for the error-free retrieval of NULL values.
Requirements
Runs on | Versions | Defined in | Include | Link to |
---|---|---|---|---|
Windows CE OS | 1.0 and later | Winbase.h | Coremain.lib |
Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.
See Also
GetLastError, SetLastError, TlsAlloc, TlsFree, TlsSetValue