Get ListView items from other windows

前端 未结 2 478
暖寄归人
暖寄归人 2020-12-03 22:59

I\'m doing some project on c#. I need to get i item from ListView window, handle of it I got by doing something like this

IntPtr pa         


        
2条回答
  •  臣服心动
    2020-12-03 23:27

    I found a C# wrapper for WinAPIs that seems to provide access to the contents of an LV from any window.
    ManagedWinapi

    using ManagedWinapi.Windows;
    using System;
    
    namespace TestApp
    {
        class Program
        {
            static void Main(string[] args)
            {
                // Create a SystemWindow object from the HWND of the ListView
                SystemWindow lvWindow = new SystemWindow((IntPtr)0x6d1d38);
    
                // Create a ListView object from the SystemWindow object
                var lv = SystemListView.FromSystemWindow(lvWindow);
    
                // Read text from a row
                var text = lv[0].Title;
            }
        }
    }
    

    Also, I have also forked mwapi here and am trying to add some new functionality - Mainly centred around colouring ListView rows, but also adding some missing p/invokes etc.

提交回复
热议问题