有没有办法获得列表视图中的子项数?

时间:2009-03-11 22:52:22

标签: c# listview interop

我正在编写一个C#应用程序,需要从驻留在外部进程中的ListView控件中提取数据。

我已经有了提取数据的代码并获取了ListView中的项目数,但是我需要等效以下子项:

    public int GetListViewRowCount()
    {
        if (list_view_handle != null)
        {
            return (int)UnManagedMethods.SendMessage(list_view_handle,
                (int)UnManagedMethods.W32_LVM.LVM_GETITEMCOUNT,
                IntPtr.Zero, IntPtr.Zero);
        }
        else return 0;
    }

我基本上是在寻找LVM_GETSUBITEMCOUNT类型消息提供的功能。

1 个答案:

答案 0 :(得分:1)

每次增加iSubItem的大小,你需要发送LVM_GETITEM(到另一个进程),直到你得到FALSE。
不要忘记指向pItem的指针需要在其他进程中有效,因此您需要在不同进程上使用分配内存的方法。 Here is the link that I used in the past.

相关问题