网站首页  词典首页

请输入您要查询的函数:

 

术语 tlsgetvalue
释义 TlsGetValue
语法:
C++
LPVOID WINAPI TlsGetValue(
__in DWORD dwTlsIndex
);
TlsGetValue功能
检索值在调用线程的线程本地存储(TLS)为指定的索引TLS的插槽。过程的每一个线程都有每个TLS索引的老虎。
参数
dwTlsIndex [in]
TLS的指数是由TlsAlloc函数分配。
返回值
如果函数成功,返回值的值存储在调用线程的TLS插槽指定索引相关联。如果dwTlsIndex是一个有效的指数成功调用对TlsAlloc分配,这个函数总是成功。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
数据存储在TLS的插槽可以有一个值为0,因为它还是有它的初始值,或者因为线程调用0的TlsSetValue功能。因此,如果返回值为0,则必须检查是否GetLastError函数返回ERROR_SUCCESS决定之前,该函数失败。如果GetLastError函数返回ERROR_SUCCESS,则函数成功和数据存储的TLS槽为0。否则,函数失败。
失败的函数调用SetLastError当他们失败返回的迹象。他们一般不调用SetLastError当他们取得成功。该TlsGetValue功能是对这个一般规则的例外。该TlsGetValue函数调用SetLastError清除线程的最后一个错误时,它成功。这使检查错误的零值免费检索。
备注
TLS的指标通常是分配给TlsAlloc函数在程序或DLL初始化。 TLS索引后,分配,过程的每一个线程可以使用它来访问自己的TLS的该指数插槽。一个线程指定在一个调用TLS的指数TlsSetValue存储在其插槽一个值。该线程在其后指定调用相同指数TlsGetValue检索存储的价值。
TlsGetValue实施作为首要目标的速度。函数执行最低参数验证和错误检查。特别是,它成功如果dwTlsIndex范围为0通过(TLS_MINIMUM_AVAILABLE - 1)。它是由程序员,以确保指数的有效,而且该线程调用TlsSetValue之前调用TlsGetValue。
实例
有关示例,请参阅使用线程本地存储或使用的动态线程本地存储链接库。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
进程和线程函数
线程本地存储
对TlsAlloc
TlsFree
TlsSetValue
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==TlsGetValue Function
Retrieves the value in the calling thread's thread local storage (TLS) slot for the specified TLS index. Each thread of a process has its own slot for each TLS index.
Syntax
C++
LPVOID WINAPI TlsGetValue(
__in DWORD dwTlsIndex
);
Parameters
dwTlsIndex [in]
The TLS index that was allocated by the TlsAlloc function.
Return Value
If the function succeeds, the return value is the value stored in the calling thread's TLS slot associated with the specified index. If dwTlsIndex is a valid index allocated by a successful call to TlsAlloc, this function always succeeds.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
The data stored in a TLS slot can have a value of 0 because it still has its initial value or because the thread called the TlsSetValue function with 0. Therefore, if the return value is 0, you must check whether GetLastError returns ERROR_SUCCESS before determining that the function has failed. If GetLastError returns ERROR_SUCCESS, then the function has succeeded and the data stored in the TLS slot is 0. Otherwise, the function has failed.
Functions that return indications of failure call SetLastError when they fail. They generally do not call SetLastError when they succeed. The TlsGetValue function is an exception to this general rule. The TlsGetValue function calls SetLastError to clear a thread's last error when it succeeds. That allows checking for the error-free retrieval of zero values.
Remarks
TLS indexes are typically allocated by the TlsAlloc function during process or DLL initialization. After a TLS index is allocated, each thread of the process can use it to access its own TLS slot for that index. 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.
TlsGetValue was implemented with speed as the primary goal. The function performs minimal parameter validation and error checking. In particular, it succeeds if dwTlsIndex is in the range 0 through (TLS_MINIMUM_AVAILABLE – 1). It is up to the programmer to ensure that the index is valid and that the thread calls TlsSetValue before calling TlsGetValue.
Examples
For an example, see Using Thread Local Storage or Using Thread Local Storage in a Dynamic-Link Library .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
Process and Thread Functions
Thread Local Storage
TlsAlloc
TlsFree
TlsSetValue
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms686812(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:26:06