How to read status Bar text for another application in MFC?

I would like to find out how to read the Status Bar text of a running application.
xewooxAsked:
Who is Participating?
 
OnegaZhangConnect With a Mentor Commented:
You need to use SB_GETTEXT message, but the memory must be allocated in target process.
A code snippet can be found in http://www.codeproject.com/threads/int64_memsteal.asp?df=100&forumid=29535&exp=0&select=1604427#xx1604427xx
Code:
//HWND hwnd=FindWindow(NULL, "Status Bar in a Dialog - Nish for CP");
//HWND hStatusBar=FindWindowEx(hwnd, NULL, "msctls_statusbar32", NULL);
HWND hwnd=FindWindow(NULL, "TEST");
HWND hStatusBar=FindWindowEx(hwnd, NULL, "StatusBar20WndClass", NULL);
unsigned long pid;
HANDLE process;
char *_item;
char item[512];
GetWindowThreadProcessId(hStatusBar, &pid);
process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_QUERY_INFORMATION, FALSE, pid);
_item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT, PAGE_READWRITE);
SendMessage(hStatusBar, SB_GETTEXT, (WPARAM)0, (LPARAM)_item);
ReadProcessMemory(process, _item, &item, 512, NULL);
printf("%s",item);
VirtualFreeEx(process, _item, 0, MEM_RELEASE);
return 0;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.