Partager via


CeTlsAlloc (Compact 2013)

3/28/2014

This function allocates a thread local storage (TLS) index and sets a cleanup function for the slot. Any thread of the process can subsequently use this index to store and retrieve values that are local to the thread.

Syntax

DWORD CeTlsAlloc(
    PFN_CETLSFREE pfnCleanup
);

Parameters

  • pfnCleanup
    [in] Specifies a cleanup function to associate with the given slot.

Return Value

If successful, this function returns a valid TLS index and associates the cleanup function with the new slot. TLS_OUT_OF_INDEXES (0xFFFFFFFF) indicates failure. To get extended error information, call GetLastError.

Remarks

Call this function in DLL_PROCESS_ATTACH to create a new slot and assign a custom cleanup function for this slot. The system calls the custom cleanup function when a thread using this slot exits or when the slot is cleared using CeTlsFree.

For a brief discussion of typical uses of the TLS functions, see the Remarks section of the TlsAlloc function.

See Also

Reference

Process and Thread Functions
CeTlsFree
TlsFree
TlsGetValue
TlsSetValue