TlsSetValue (Compact 2013)
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.
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
TLS indexes are typically allocated by the TlsAlloc function 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 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.
The primary goal of TlsSetValue and TlsGetValue is speed. These functions perform minimal parameter validation and error checking. In particular, this function succeeds if dwTlsIndex is in the range zero through (TLS_MINIMUM_AVAILABLE - 1). You must ensure that the index is valid.