开发者

Get text of LVITEM with LVM_GETITEM and SendMessage in C

开发者 https://www.devze.com 2023-01-31 19:08 出处:网络
I\'m trying to read text off the listview of another process. So far I have been able to get the count of rows and columns. Now I want to go through each cell and read it. I did a little bit of resear

I'm trying to read text off the listview of another process. So far I have been able to get the count of rows and columns. Now I want to go through each cell and read it. I did a little bit of research, and I found that I needed to use SendMessage to get the LVITEM of each cell. I think LVITEM.iItem has to be the row #, and LVITEM.iSubItem, has to be the column #. Also how would I go about getting the text into my char*. I saw some examples using CString::GetBuffer. But I'm in c so I don't have that, is there an equivalent or some other way to do that?

char* itemText;

LVITEM itemInfo = {0};
itemInfo.iItem = r; // r is an int. this should be row # right?
itemInfo.iSubItem = c; // c is an int, this should be开发者_如何学JAVA the column # right?
itemInfo.mask = LVIF_TEXT;
itemInfo.cchTextMax = 256;
itemInfo.pszText = itemText;
SendMessage(procList, 0x1005, 0, (LPARAM)&itemInfo);


Because the memory block that contains the text is owned by the other process, you will need to pull a few tricks to marshal the text from the process into your process.

Here is a blog post I did back in 2004 demonstrating how this can be done. Beware, you will need to have Admin rights to do this.

http://taylorza.blogspot.com/2009/08/archive-hacking-my-way-across-process.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号