簡體   English   中英

從第三方應用程序獲取列表視圖

[英]Get listview from third party application

我正在嘗試從第三方應用程序獲取列表視圖,這是我試圖完成此操作的方式

   [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
    static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, StringBuilder lParam);
    const int LVM_GETITEMCOUNT = 0x018B;
    const int LVM_GETITEMTEXT = 0x0189;

    // Get ListBox contents hwnd
    private List<string> GetListViewContents(IntPtr listviewHwnd)
    {
        int cnt = (int)SendMessage(listviewHwnd, LVM_GETITEMCOUNT, IntPtr.Zero, null);
        List<string> listViewContents = new List<string>();
        for (int i = 0; i < cnt; i++)
        {
            StringBuilder sb = new StringBuilder(256);
            IntPtr getText = SendMessage(listviewHwnd, LVM_GETITEMTEXT, (IntPtr)i, sb);
            listViewContents.Add(sb.ToString());
         }
        return listViewContents;
    }

然后,我使用UISpy獲取應用程序上listview屬性的句柄,並使用以下代碼填充我的應用程序列表框:

     IntPtr ks = new IntPtr(0x00040FA8); // temp handle for the 3rd party listview
     listBox1.DataSource = GetListViewContents(ks);

沒有返回數據,這是什么問題?

按照http://msdn.microsoft.com/en-us/library/windows/desktop/bb761055(v=vs.85).aspx ,您正在將StringBuffer傳遞給期望具有特定結構的對象。

您應該看看從SysListView32以64位格式獲取文本

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM