Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get text from non-owned StatusBar

18 views
Skip to first unread message

Tobias Nissen

unread,
Mar 13, 2007, 1:00:11 PM3/13/07
to
Hi,

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

Waleri Todorov

unread,
Mar 13, 2007, 3:12:52 PM3/13/07
to
SB_GETTEXT
SB_GETTEXTLENGTH

"Tobias Nissen" <ma...@tobiasnissen.de> wrote in message
news:45f6d89a$0$23142$9b4e...@newsspool1.arcor-online.net...

Michael K. O'Neill

unread,
Mar 13, 2007, 3:22:05 PM3/13/07
to
Those messages probably won't work across processes.

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

unread,
Mar 14, 2007, 12:36:52 AM3/14/07
to
SB_GETTEXTLENGTH at least should across processes work because there is
no data to marshal.

--

- Gary Chanson (Windows SDK MVP)
- Abolish Public Schools

"Michael K. O'Neill" <MikeAT...@nospam.hotmail.com> wrote in message
news:#2hUkTaZ...@TK2MSFTNGP05.phx.gbl...

Christian ASTOR

unread,
Mar 14, 2007, 6:19:39 AM3/14/07
to
On 13 mar, 18:00, Tobias Nissen <m...@tobiasnissen.de> wrote:

> I need to get the text from a part (not the first) of a non-owned
> msctls_statusbar32 object.

VirtualAllocEx()-WriteProcessMemory()-SB_GETTEXT-ReadProcessMemory()

Tobias Nissen

unread,
Mar 15, 2007, 3:45:19 AM3/15/07
to
Christian ASTOR wrote:
>> 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;
}

0 new messages