예제 #1
0
        public bool TopReport(int hwnd, int lParam)//static
        {
            //Console.Write("child handle is :");
            //Console.WriteLine(hwnd);

            IntPtr lpString2 = Marshal.AllocHGlobal(200);

            GetClassName(hwnd, lpString2, 200);
            var className = Marshal.PtrToStringAnsi(lpString2);

            if (exclude.Count > 0 && exclude.Contains(className))
            {
                return(true);
            }

            IntPtr lpString = Marshal.AllocHGlobal(200);

            GetWindowText(hwnd, lpString, 200);
            var text = Marshal.PtrToStringAnsi(lpString);

            int parent = GetParent(hwnd);

            HandleInfo hinfo = new HandleInfo(new IntPtr(hwnd), text, className);

            hinfo.Parent = parent;

            Console.WriteLine("--hwnd:" + hinfo.Handle + " handle2:" + hinfo.Handle2 + " parent:" + hinfo.Parent + " parent2:" + hinfo.Parent2 + " text:" + text + " class:" + className);

            toplist.Add(hinfo);
            return(true);
        }
예제 #2
0
        public ArrayList getChildWindows(IntPtr myhwnd, ArrayList data)
        {
            ArrayList list2 = new ArrayList();

            for (int i = 0; i < data.Count; i++)
            {
                HandleInfo hinfo = (HandleInfo)data[i];
                if (hinfo.Parent == myhwnd.ToInt32())
                {
                    list2.Add(hinfo);
                }
            }
            return(list2);
        }
예제 #3
0
        public ArrayList getEnumWindows2(IntPtr ParentHandle)
        {
            Win32Service ws          = new Win32Service();
            ArrayList    list        = new ArrayList();
            IntPtr       ChildHandle = IntPtr.Zero;

            ChildHandle = FindWindowEx(ParentHandle, ChildHandle, null, null);

            int i = 0;

            while (ChildHandle.ToInt32() > 0)
            {
                IntPtr lpString2 = Marshal.AllocHGlobal(200);
                GetClassName(ChildHandle.ToInt32(), lpString2, 200);
                var className = Marshal.PtrToStringAnsi(lpString2);
                if (exclude.Count > 0 && exclude.Contains(className))
                {
                    ChildHandle = FindWindowEx(ParentHandle, ChildHandle, null, null);
                    continue;
                }

                IntPtr lpString = Marshal.AllocHGlobal(200);
                GetWindowText(ChildHandle.ToInt32(), lpString, 200);
                var text = Marshal.PtrToStringAnsi(lpString);

                if (ws.children && (ws.include.Count > 0 && ws.include.Exists(item => text.Contains(item))))
                {
                }

                HandleInfo hinfo = new HandleInfo(ChildHandle, text);
                hinfo.ClassName = className;
                list.Add(hinfo);

                Console.WriteLine("i:" + i.ToString() + " handle:" + hinfo.Handle.ToString() + " handle2:" + hinfo.Handle2 + " text: " + hinfo.Text + " class:" + hinfo.ClassName);
                i++;
                ChildHandle = FindWindowEx(ParentHandle, ChildHandle, null, null);
            }

            //int i2 = list.Count;
            return(list);
        }
예제 #4
0
 public static string getNodeShow(HandleInfo hinfo)
 {
     return("(" + hinfo.Index + "){" + hinfo.Parent + "}{" + hinfo.Parent2 + "}[" + hinfo.Handle + "][" + hinfo.Handle2 + "]~" + hinfo.Text + "~" + hinfo.ClassName);
 }