zoukankan      html  css  js  c++  java
  • 获取其它进程窗口中的状态栏信息(FindWindowEx GetWindowThreadProcessId OpenProcess SendMessage轮番轰炸)

    [cpp] view plain copy
     
      1.  HWND hWnd = ::FindWindow(NULL, _T("XXXXX"));   
      2.  if(NULL == hWnd)  
      3.  {  
      4.   return ;  
      5.  }  
      6.    
      7.  HWND hWndStatusBar = ::FindWindowEx(hWnd, NULL, _T("msctls_statusbar32"), NULL);  
      8.  if(NULL == hWndStatusBar)  
      9.  {  
      10.   return ;  
      11.  }  
      12.    
      13.  DWORD dwProcessId = 0;  
      14.  GetWindowThreadProcessId(hWnd, &dwProcessId);  
      15.    
      16.  HANDLE hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, dwProcessId);  
      17.  if(NULL == hProcess)  
      18.  {  
      19.   return ;  
      20.  }  
      21.    
      22.  LRESULT nCount = ::SendMessage(hWndStatusBar, SB_GETPARTS, 0, 0);  
      23.  LPVOID pBuf = VirtualAllocEx(hProcess, NULL, MAX_PATH, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);  
      24.  if(NULL != pBuf)  
      25.  {  
      26.   TCHAR buf[MAX_PATH] = {0};  
      27.   DWORD dwRead = 0;  
      28.   for(int i=0; i<(int)nCount; i++)  
      29.   {  
      30.    ::SendMessage(hWndStatusBar, SB_GETTEXT, i, (LPARAM)pBuf);  
      31.    if(ReadProcessMemory(hProcess, pBuf, buf, sizeof(buf), &dwRead))  
      32.    {  
      33.     AfxMessageBox(buf);  
      34.    }     
      35.   }    
      36.   VirtualFreeEx(hProcess, pBuf, 0, MEM_RELEASE);   
      37.  }  
      38.  CloseHandle(hProcess);  

    http://blog.csdn.net/visualeleven/article/details/7286517

  • 相关阅读:
    java web
    java web
    java
    周末总结7
    java
    java
    java
    java
    java web
    java
  • 原文地址:https://www.cnblogs.com/findumars/p/6002447.html
Copyright © 2011-2022 走看看