// dllmain.cpp : 定义 DLL 应用程序的入口点。 #include "stdafx.h" const char* g_szMouldPath = nullptr; BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: { char* pName = new char[MAX_PATH]; if (GetModuleFileName(hModule, pName, MAX_PATH - 1)) { g_szMouldPath = const_cast(pName); } else { printf("\r\n Get mould path failed %d \r\n", GetLastError()); } break; } case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: { if (g_szMouldPath != nullptr) { delete[] g_szMouldPath; g_szMouldPath = nullptr; } break; } } return TRUE; }