Smith han
Smith han

Reputation: 31

get itemtext from SysListView32

i am trying to get the text in SysListView32 from another app by C#. i can get the LVM_GETITEMCOUNT well but LVM_GETITEMW = 0x1000 + 13 always returns -1. how can i get the text by C#? i am new. thanks very much!

        ParenthWnd = FindWindow(ParentClass, ParentWindow);
        if (!ParenthWnd.Equals(IntPtr.Zero))
        {
            zWnd = FindWindowEx(ParenthWnd, zWnd, zClass, zWindow);
            if (!zWnd.Equals(IntPtr.Zero))
            {
                int user = SendMessage(zWnd, LVM_GETITEMCOUNT, 0, 0);
            }

Upvotes: 3

Views: 2231

Answers (1)

David Heffernan
David Heffernan

Reputation: 613252

You need to work harder to read and write the LVITEM memory since you are working with a control owned by another process. You therefore need to read and write memory in that process. You can't do that without calling ReadProcessMemory, WriteProcessMemory etc.

The most commonly cited example of the techniques involved is this Code Project article: Stealing Program's Memory. Watch out for 32/64 bit gotchas.

Upvotes: 2

Related Questions