void OnCommand(HWND hDlg, int id, HWND hwndCtl, UINT codeNotify) { switch (id) { case IDC_BUTTON1: setMyHook(hDlg); break; case IDC_BUTTON2: clearMyHook(hDlg); break; case IDC_BUTTON3: EndDialog(hDlg, 0); clearMyHook(hDlg); break; } }
BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD Reason, LPVOID reserved) { switch(Reason) { case DLL_PROCESS_ATTACH: hInstance = hInst; UWM_CHANGEHOOK = RegisterWindowMessage(UWM_CHANGE_HOOK_MSG); return TRUE; case DLL_PROCESS_DETACH: if(HwndServer != NULL) clearMyHook(HwndServer); return TRUE; } }