I need to get the text from a part (not the first) of a non-owned
msctls_statusbar32 object. I was told that getting the text of the
first part is trivial, because a simple WM_GETTEXT would do.
Also, I have been given hints in order what to do, to get the text of
any other part, but being no win32-programmer, I'm not capable to do
that on my own.
Does someone have a piece of code or in-depth instructions on how to
deal with the problem?
Thanks in advance!
Tobias
"Tobias Nissen" <ma...@tobiasnissen.de> wrote in message
news:45f6d89a$0$23142$9b4e...@newsspool1.arcor-online.net...
In theory, WM_GETTEXT also shouldn't work across processes, but it does, for
legacy reasons going back to Win16.
"Waleri Todorov" <wal...@invalid.domain.com> wrote in message
news:O0rkNOa...@TK2MSFTNGP06.phx.gbl...
--
- Gary Chanson (Windows SDK MVP)
- Abolish Public Schools
"Michael K. O'Neill" <MikeAT...@nospam.hotmail.com> wrote in message
news:#2hUkTaZ...@TK2MSFTNGP05.phx.gbl...
> I need to get the text from a part (not the first) of a non-owned
> msctls_statusbar32 object.
VirtualAllocEx()-WriteProcessMemory()-SB_GETTEXT-ReadProcessMemory()
Thank you! That helped to improve my Google-query. I got to
http://www.codeproject.com/threads/int64_memsteal.asp?df=100&forumid=29535&exp=0&select=1604427&tid=1604427#xx1604427xx
and ended up with the following code:
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <commctrl.h>
using namespace std;
int main(int argc, char *argv[])
{
HWND hwnd = FindWindow("someclassname", NULL);
HWND hStatusBar = FindWindowEx(hwnd, NULL, "TStatusBar", 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);
int i = 0;
for (i = 0; i < 8; i++) {
SendMessage(hStatusBar, SB_GETTEXT, (WPARAM)i, (LPARAM)_item);
ReadProcessMemory(process, _item, &item, 512, NULL);
printf("content of part %2d: \"%s\"\n", i, item);
}
VirtualFreeEx(process, _item, 0, MEM_RELEASE);
return EXIT_SUCCESS;
}