123456

 

DisableThreadLibraryCalls

 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_ATTACHDLL_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;
}


 

posted on 2011-12-02 12:45  hgy413  阅读(379)  评论(0编辑  收藏  举报

导航