1 #include <windows.h> 2 3 #ifdef BUILD_DLL 4 #define DLL_EXPORT __declspec(dllexport) 5 #else 6 #define DLL_EXPORT 7 #endif 8 9 // a sample exported function SomeFunction(const LPCSTR sometext)10void DLL_EXPORT SomeFunction(const LPCSTR sometext) 11 { 12 MessageBoxA(0, sometext, "DLL Message", MB_OK | MB_ICONINFORMATION); 13 } 14 DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)15BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 16 { 17 switch (fdwReason) 18 { 19 case DLL_PROCESS_ATTACH: 20 // attach to process 21 // return FALSE to fail DLL load 22 break; 23 24 case DLL_PROCESS_DETACH: 25 // detach from process 26 break; 27 28 case DLL_THREAD_ATTACH: 29 // attach to thread 30 break; 31 32 case DLL_THREAD_DETACH: 33 // detach from thread 34 break; 35 } 36 return TRUE; // succesful 37 } 38