您的位置:首页 > 其它

DisableThreadLibraryCalls

2011-12-02 12:45 447 查看
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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: