• 获取其它进程窗口中的状态栏信息(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

  • 相关阅读:
    <Redis开发与运维> 阅读笔记
    请求行,请求头,请求体详解
    char 与 varchar 的区别
    python字符串的常用方法。
    快速排序的代码及原理
    C#之Dictionary源码
    C#中构造函数
    U3D——单例模式的用法
    U3D学习——设置VS2019作为开发工具
    U3D学习——脚本运行周期
  • 原文地址:https://www.cnblogs.com/findumars/p/6002447.html
Copyright © 2020-2023  润新知