Get header text of column from SysHeader32

1k Views Asked by At

I'm working on an C# application that have to capture data from other appication (unmanaged).

This another application has many SysListView32 controls and I'll have to get the data of a specific SysListView32 control, but the only thing that I can use to get this specific control is the column's header (SysHeader32) text, they are different for each SysListView32 control.

I got capture the data (all texts from rows and columns) from the all SysListView32 controls, but I can't capture the text of header columns.

Anybody can help me?

Thanks and sorry for my bad english.

1

There are 1 best solutions below

2
On

You will need to send the control a LVM_GETCOLUMN message. The difficulty is that the message fills the contents of a struct that is passed as a pointer to the struct. But that pointer must refer to memory allocated in the process which owns the list view. In your scenario the list view is owned by a different process.

You can work around this by using VirtualAlloc to allocate memory in the other processes. You can then initialize that memory with WriteProcessMemory. Then send the message before reading the contents using ReadProcessMemory. Finally, deallocate with VirtualFree.

This is quite a fiddle to get right, and it's even more complicated if the target process is a different bitness.

Having seen your comment to the question, it's clear that you are already familiar with this technique.

In my opinion, you may well be better off using the automation API, which I believe will give you the information much more readily.