#include "HGDef.h" #include "HGInfoImpl.hpp" #include "HGInc.h" #if defined(HG_CMP_MSC) #include #include static ULONG_PTR g_nToken = 0; HGInfoImpl* g_infoImpl = NULL; BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: { Gdiplus::GdiplusStartupInput input; Gdiplus::GdiplusStartupOutput output; Gdiplus::GdiplusStartup(&g_nToken, &input, &output); assert(0 != g_nToken); g_infoImpl = new HGInfoImpl; } break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: { delete g_infoImpl; g_infoImpl = NULL; Gdiplus::GdiplusShutdown(g_nToken); g_nToken = 0; } break; } return TRUE; } #else HGInfoImpl* g_infoImpl = NULL; void __attribute__((constructor)) global_load(void); void __attribute__((destructor)) global_unload(void); void global_load(void) { g_infoImpl = new HGInfoImpl; } void global_unload(void) { delete g_infoImpl; g_infoImpl = NULL; } #endif