MFC Hook 拦劫 HCBT_DESTROYWND消息

#include <windows.h>

 

#pragma data_seg(".luck")

HHOOK hook=NULL;

#pragma data_seg()

 

LRESULT CALLBACK GetMsgPr(int code,WPARAM wParam,LPARAM lParam)

{

  if(code>0)

  {

    if (code==HCBT_DESTROYWND)

    {

      MessageBoxA(0,"已经拦截到关闭消息","提示",64);

      return 1;

    }

 

  }

   return  CallNextHookEx(hook,code,wParam,lParam);

}

 

int WINAPI onhook()

{

  hook=SetWindowsHookExA(WH_CBT,GetMsgPr,GetModuleHandleA("hook.dll"),0);

  return (int)hook;

}

 

 

BOOL WINAPI unhook()

{

  return UnhookWindowsHookEx(hook);

}

 

你可能感兴趣的:(mfc,callback,include,hook,winapi)