gcc -c newfile.c gcc -shared -o newfile.dll newfile.o |
#include <windows.h> #include <stdio.h> #ifndef NEWFILE_H #define NEWFILE_H #ifdef __cplusplus extern "C" { #endif __declspec(dllexport) void __stdcall MyFirstHook(){ printf("It works!"); } #ifdef __cplusplus } #endif #endif /* NEWFILE_H */ |
#include <windows.h> int main() { HOOKPROC hkprcSysMsg; HINSTANCE hinstDLL; HHOOK hhookSysMsg; hinstDLL = LoadLibrary(TEXT("newfile.dll")); hkprcSysMsg = (HOOKPROC)GetProcAddress(hinstDLL, "MyFirstHook"); hhookSysMsg = SetWindowsHookEx(WH_KEYBOARD, hkprcSysMsg, hinstDLL,0); return (EXIT_SUCCESS); } |
|
|