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.
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
//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);
_item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT, PAGE_READWRITE);
SendMessage(hStatusBar, SB_GETTEXT, (WPARAM)0, (LPARAM)_item);
ReadProcessMemory(process, _item, &item, 512, NULL);
VirtualFreeEx(process, _item, 0, MEM_RELEASE);
return 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.