DisableThreadLibraryCalls 的MSDN解释是这样的:
The DisableThreadLibraryCalls function lets a DLL disable the DLL_THREAD_ATTACH and DLL_THREAD_DETACH notification calls.
就是不接收这两个消息,
his 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.
对多线程应用程序,该函数在有许多DLL,频繁创建和删除线程,并且DLL不需要线程级消息如DLL_THREAD_ATTACH and DLL_THREAD_DETACH时的多线程应用中是很有效的优化。
Do not call this function from a DLL that is linked to the static C run-time library (CRT). The static CRT requires DLL_THREAD_ATTACH and DLL_THREAD_DETATCH notifications to function properly.
不要从一个链接到静态C运行时库(CRT)的DLL调用此功能。静态CRT需要DLL_THREAD_ATTACH和DLL_THREAD_DETATCH通知才能正常工作。
BOOL APIENTRY DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved ){ switch (dwReason) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: { ::DisableThreadLibraryCalls((HMODULE)hModule); } break; } return TRUE;}