typedef void WINAPI (MYPROC)(HWND,char*)
gcc -Wall -W toto_dll.c -mdll -o toto.dll -Wl,--kill-at
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionextern "C" void __stdcall show_msg(HWND hWnd, char *msg) { MessageBox(hWnd, msg, "Dll Powa - Yeah !", MB_OK); } BOOL APIENTRY DllMain(HANDLE 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; }
LIBRARY test_dll EXPORTS show_msg
typedef void (__stdcall *MYPROC)(HWND hWnd, char *msg); HMODULE dll; MYPROC show_msg; [...] dll = LoadLibrary("test_dll.dll"); if (dll == NULL) MessageBox(NULL, "Can't load library", "Error", MB_OK); else { show_msg = (MYPROC)GetProcAddress(dll, "test_bordel_de_merde"); if (show_msg == NULL) { error = GetLastError(); sprintf(msg, "Error code : %lu", error); MessageBox(NULL, msg, "Error", MB_OK); } else (show_msg)(hWnd, "Ceci est un test :)"); FreeLibrary(dll); }
show_msg = (MYPROC)GetProcAddress(dll, "test_bordel_de_merde");
[..] show_msg = (MYPROC)GetProcAddress (dll, "test_bordel_de_merde"); if (show_msg == NULL) [...]