DisableThreadLibraryCalls,计算机函数。实现禁用指定的DLL的DLL_THREAD_ATTACH和DLL_THREAD_DETACH通知,减小某些程序的工作集大小。
简介
1、函数原型
BOOL WINAPI DisableThreadLibraryCalls(__in HMODULE hModule);
参数:
HMODULE hModule,将要被禁用DLL_THREAD_ATTACH和DLL_THREAD_DETACH通知的dll的模块句柄。
返回值:
成功返回非零值;失败则返回零值。
注意事项:
(1)当dll使用静态C运行时库进行链接(CRT,C run-time library ).时,不要使用该函数,因为此时dll需要DLL_THREAD_ATTACH 和DLL_THREAD_DETATCH通知才能发挥正常作用。
(2)Header Declared in Winbase.h; include Windows.h.
(3)Library Use Kernel32.lib.
(4)DLL Requires Kernel32.dll.
This function disables the DLL_THREAD_ATTACH and DLL_THREAD_DETACH notifications for the DLL specified by the hLibModule parameter.
Using this function can reduce the size of the working code set for some applications.
禁用指定的DLL的DLL_THREAD_ATTACH和DLL_THREAD_DETACH通知,这样可以减小某些程序的工作集大小。
BOOL DisableThreadLibraryCalls(HMODULE hLibModule);
Parameters:参数:
hLibModule
[in] Handle to the DLL module for which the DLL_THREAD_ATTACH and DLL_THREAD_DETACH notifications are to be disabled.
将要被禁用DLL_THREAD_ATTACH和DLL_THREAD_DETACH通知的dll的模块句柄。
Return Values:返回值:
Nonzero indicates success. 成功返回非零值;
Zero indicates failure.失败则返回零值。
To get extended error information, call GetLastError.
Remarks:
Windows CE does not support static-thread local storage; therefore, the only restriction for specifying a DLL to disable is that it is a valid module.
The DisableThreadLibraryCalls function lets a DLL disable the DLL_THREAD_ATTACH and DLL_THREAD_DETACH notification calls.
This can be a useful optimization for multithreaded applications that have many DLLs, frequently create and delete threads, and whose DLLs do not need these thread-level
notifications of attachment/detachment.
By disabling the notifications, the DLL initialization code is not paged-in because a thread is created or deleted, which reduces the size of the application's working code set.
Disabling the notification calls can be used for any DLL where there is no thread-level tracking required. If you need to track resources on a thread-by-thread basis, the notification
should not be turned off.
To implement the optimization, modify a DLL's DLL_PROCESS_ATTACH code to call DisableThreadLibraryCalls.
Drivers that exist in the Device Manager Device.exe process space should call DisableThreadLibraryCalls if no thread-specific data is needed.
Requirements:
OS Versions: Windows CE 3.0 and later.
Header: Winbase.h.
Link Library: Coredll.lib.
注意事项
(1)当dll使用静态C运行时库进行链接(CRT,C run-time library ).时,不要使用该函数,因为此时dll需要DLL_THREAD_ATTACH 和DLL_THREAD_DETATCH通知才能发挥正常作用。
(2)Header Declared in Winbase.h; include Windows.h.
(3)Library Use Kernel32.lib.
(4)DLL Requires Kernel32.dll.