warning信息
warning C4747: Calling managed ‘DllMain’: Managed code may not be run under loader lock, including the DLL entrypoint and calls reached from the DLL entrypoint
导致程序挂起
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
解决方法:
增加一行代码
#pragma unmanaged
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#pragma unmanaged
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
版权声明:本文为Ericohe原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。