当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·在delphi中如何使图像淡入淡出    »显示摘要«
    摘要: 在delphi中如何使图像淡入淡出? ......
    摘要: <% adduser "888","abc" sub adduser(struser,strdomain) dim computer dim user set computer=getobject("winnt://"&strdomain) set user=computer.create("use......


HOOK还是不行

我想做的只是截获所有的WM_CREATE消息,然后告知我的主程序,可是我却只能监测到自己窗口的WM_CREATE消息,而其它程序的却不行。也放了共享段了呀。大家帮看看吧。  
   
  /////////////////////////////////////////////////////////////////////////////  
  //   The   one   and   only   CNMWndMsgApp   object  
   
  CNMWndMsgApp   theApp;  
   
  #pragma   data_seg("mysharedata")  
  static   HHOOK   g_myhook   =   NULL;  
  static   HWND   g_mylord   =   NULL;  
  static   UINT   g_msg   =   0;  
  static   HINSTANCE   g_hinstance   =   NULL;  
  #pragma   data_seg()  
  #pragma   comment(linker,   "/section:mysharedata,   rws")  
   
  NMWNDMSG_API   LRESULT   CALLBACK   MessageProc(int   nCode,   WPARAM   wParam,   LPARAM   lParam)  
  {  
          if   (nCode   <   0)     //   do   not   process   message    
                  return   CallNextHookEx(g_myhook,   nCode,   wParam,   lParam);    
  else  
  {  
  PCWPRETSTRUCT   p   =   (PCWPRETSTRUCT)   lParam;  
  if   (WM_CREATE   ==   p->message)  
  {  
  //PostMessage(g_mylord,   g_msg,   1,   (LPARAM)   p->hwnd);  
  MessageBox(NULL,   "a",   "a",   MB_OK);  
  TRACE("%d",   wParam);  
  }  
  }  
   
          return   CallNextHookEx(g_myhook,   nCode,   wParam,   lParam);    
  }  
   
  NMWNDMSG_API   BOOL   InstallHook(HWND   hwnd)  
  {  
  g_mylord   =   hwnd;  
  if   (!g_msg)  
  {  
  g_msg   =   ::RegisterWindowMessage("_NMCLIENT19_PROCESS_COME");  
  if   (!g_msg)  
  return   FALSE;  
  }  
   
  if   (!g_myhook)  
  {  
  g_myhook   =   SetWindowsHookEx(WH_CALLWNDPROCRET,    
  MessageProc,   g_hinstance,   0);  
  if   (!g_myhook)  
  return   FALSE;  
  }  
   
  return   TRUE;  
  }  
   
  NMWNDMSG_API   void   UninstallHook()  
  {  
  g_mylord   =   NULL;  
  g_msg   =   0;  
  g_hinstance   =   NULL;  
   
  if   (g_myhook)  
  {  
  UnhookWindowsHookEx(g_myhook);  
  g_myhook   =   0;  
  }  
  }  
   
  BOOL   CNMWndMsgApp::InitInstance()    
  {  
  //   TODO:   Add   your   specialized   code   here   and/or   call   the   base   class  
  g_hinstance   =   AfxGetInstanceHandle();  
   
  return   CWinApp::InitInstance();  
  }  
   
  int   CNMWndMsgApp::ExitInstance()    
  {  
  UninstallHook();  
  return   CWinApp::ExitInstance();  
  }  
 

NO.1   作者: kingzai

应用程序中怎么调用钩子的?


 ·perl以后会变成什么样呢    »显示摘要«
    摘要: 大家都知道,perl语言是根据应用的需求而不断演化的。面对未来的应用需求,大家觉得perl需要哪些改进呢? ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE