- HWND hWnd = ::FindWindow(NULL, _T("XXXXX"));
- if(NULL == hWnd)
- {
- return ;
- }
- HWND hWndStatusBar = ::FindWindowEx(hWnd, NULL, _T("msctls_statusbar32"), NULL);
- if(NULL == hWndStatusBar)
- {
- return ;
- }
- DWORD dwProcessId = 0;
- GetWindowThreadProcessId(hWnd, &dwProcessId);
- HANDLE hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, dwProcessId);
- if(NULL == hProcess)
- {
- return ;
- }
- LRESULT nCount = ::SendMessage(hWndStatusBar, SB_GETPARTS, 0, 0);
- LPVOID pBuf = VirtualAllocEx(hProcess, NULL, MAX_PATH, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
- if(NULL != pBuf)
- {
- TCHAR buf[MAX_PATH] = {0};
- DWORD dwRead = 0;
- for(int i=0; i<(int)nCount; i++)
- {
- ::SendMessage(hWndStatusBar, SB_GETTEXT, i, (LPARAM)pBuf);
- if(ReadProcessMemory(hProcess, pBuf, buf, sizeof(buf), &dwRead))
- {
- AfxMessageBox(buf);
- }
- }
- VirtualFreeEx(hProcess, pBuf, 0, MEM_RELEASE);
- }
- CloseHandle(hProcess);
http://blog.csdn.net/visualeleven/article/details/7286517