static IEnumerable <IntPtr> EnumerateProcessWindowHandles(int processID)
        {
            List <IntPtr> handles = new List <IntPtr>();

            EnumThreadDelegate addWindowHandle = delegate(IntPtr hWnd, IntPtr param)
            {
                string className = GetDaClassName(hWnd);

                switch (className)
                {
                case null:
                    break;

                case "ExploreWClass":
                    handles.Add(hWnd);
                    break;

                case "CabinetWClass":
                    handles.Add(hWnd);
                    break;

                default:
                    break;
                }

                return(true);
            };

            foreach (ProcessThread thread in Process.GetProcessById(processID).Threads)
            {
                EnumThreadWindows(thread.Id, addWindowHandle, IntPtr.Zero);
            }

            return(handles);
        }
Exemplo n.º 2
0
        public static IEnumerable <IntPtr> EnumerateProcessWindowHandles(int processID)
        {
            List <IntPtr> handles = new List <IntPtr>();

            EnumThreadDelegate addWindowHandle = delegate(IntPtr hWnd, IntPtr param)
            {
                string className = GetDaClassName(hWnd);

                switch (className)
                {
                case null:
                    break;

                case "ExploreWClass":
                    handles.Add(hWnd);
                    break;

                case "CabinetWClass":
                    handles.Add(hWnd);
                    break;

                case "IEFrame":
                    handles.Add(hWnd);
                    break;

                case "HelpAlert_MainWindow":
                    handles.Add(hWnd);
                    break;

                case "WindowsForms10.Window.8.app.0.201d787":
                    handles.Add(hWnd);
                    break;

                case "WindowsForms10.Window.8.app.0.31e27ec":
                    handles.Add(hWnd);
                    break;

                default:
                    //Debug.WriteLine(className.ToString());
                    break;
                }

                return(true);
            };

            foreach (ProcessThread thread in Process.GetProcessById(processID).Threads)
            {
                EnumThreadWindows(thread.Id, addWindowHandle, IntPtr.Zero);
            }

            return(handles);
        }
Exemplo n.º 3
0
    public static IntPtr GetMainWin(string Prc, string Cl, string N, string n)
    {
        uint pid = 0; InputData.Result = IntPtr.Zero; Process p;

        for (int i = 0; i < WApi.GetProcessIDNum(Prc); i++)
        {
            GetWindowThreadProcessId(GetProcessID(Prc, i), out pid);
            var callback = new EnumThreadDelegate(WApi.ThreadWindows);
            p = Process.GetProcessById((int)pid);
            InputData.PName = Prc; InputData.WClass = Cl; InputData.BName = N; InputData.EName = n;
            if ((N != "") && (n != ""))
            {
                foreach (ProcessThread thread in Process.GetProcessById((int)pid).Threads)
                {
                    EnumThreadWindows(thread.Id, callback, IntPtr.Zero);
                    if (InputData.Result != IntPtr.Zero)
                    {
                        return(InputData.Result);
                    }
                }
            }
            if (N != "")
            {
                callback = new EnumThreadDelegate(WApi.ThreadWindows1);
                foreach (ProcessThread thread in Process.GetProcessById((int)pid).Threads)
                {
                    EnumThreadWindows(thread.Id, callback, IntPtr.Zero);
                    if (InputData.Result != IntPtr.Zero)
                    {
                        return(InputData.Result);
                    }
                }
            }
            if (n != "")
            {
                callback = new EnumThreadDelegate(WApi.ThreadWindows2);
                foreach (ProcessThread thread in Process.GetProcessById((int)pid).Threads)
                {
                    EnumThreadWindows(thread.Id, callback, IntPtr.Zero);
                    if (InputData.Result != IntPtr.Zero)
                    {
                        return(InputData.Result);
                    }
                }
            }
        }
        return(InputData.Result);
    }
Exemplo n.º 4
0
        public static IList <IntPtr> GetWindowsByThread(int threadId)
        {
            var windows = new List <IntPtr>();
            EnumThreadDelegate callback = delegate(IntPtr hWnd, IntPtr lParam)
            {
                if (IsWindowVisible(hWnd))
                {
                    windows.Add(hWnd);
                }

                return(true);
            };

            EnumThreadWindows((uint)threadId, callback, IntPtr.Zero);

            return(windows);
        }
Exemplo n.º 5
0
        static IEnumerable <IntPtr> EnumerateProcessWindowHandles(int processID)
        {
            List <IntPtr> handles = new List <IntPtr>();

            EnumThreadDelegate addWindowHandle = delegate(IntPtr hWnd, IntPtr param)
            {
                string className = GetDaClassName(hWnd);        //hWnd is the handle to a window. A handle is an abstract reference to a resource
                //Every hWnd is a handle, but not every handle is a hWnd

                switch (className)
                {
                case null:
                    break;

                case "ExploreWClass":                       //if the folder tree view is enabled, i.e if the explorer is opened by winkey+E or from start, we get the ExploreWClass, else CabinetWClass
                    handles.Add(hWnd);
                    break;

                case "CabinetWClass":
                    handles.Add(hWnd);
                    break;

                default:
                    break;
                }

                return(true);
            };

            foreach (ProcessThread thread in Process.GetProcessById(processID).Threads)
            {
                EnumThreadWindows(thread.Id, addWindowHandle, IntPtr.Zero);
            }

            return(handles);
        }
Exemplo n.º 6
0
 public static extern bool EnumThreadWindows(int threadId, EnumThreadDelegate pfnEnum, IntPtr lParam);
Exemplo n.º 7
0
 [DllImport("user32.dll")] static extern bool EnumThreadWindows(uint threadId, EnumThreadDelegate lpfn, IntPtr lParam);
 public static extern bool EnumChildWindows(IntPtr hwndParent, EnumThreadDelegate lpEnumFunc, IntPtr lParam);
Exemplo n.º 9
0
 private static extern bool EnumThreadWindows(uint threadId, EnumThreadDelegate lpfn, IntPtr lParam);
Exemplo n.º 10
0
 public static IntPtr GetMainWin(string Prc, string Cl, string N, string n)
 {
     uint pid = 0; InputData.Result = IntPtr.Zero; Process p;
     for (int i = 0; i < WApi.GetProcessIDNum(Prc); i++)
     {
         GetWindowThreadProcessId(GetProcessID(Prc, i), out pid);
         var callback = new EnumThreadDelegate(WApi.ThreadWindows);
         p = Process.GetProcessById((int)pid);
         InputData.PName = Prc; InputData.WClass = Cl; InputData.BName = N; InputData.EName = n;
         if ((N != "") && (n != ""))
         {
             foreach (ProcessThread thread in Process.GetProcessById((int)pid).Threads)
             {
                 EnumThreadWindows(thread.Id, callback, IntPtr.Zero);
                 if (InputData.Result != IntPtr.Zero) return InputData.Result;
             }
         }
         if (N != "")
         {
             callback = new EnumThreadDelegate(WApi.ThreadWindows1);
             foreach (ProcessThread thread in Process.GetProcessById((int)pid).Threads)
             {
                 EnumThreadWindows(thread.Id, callback, IntPtr.Zero);
                 if (InputData.Result != IntPtr.Zero) return InputData.Result;
             }
         }
         if (n != "")
         {
             callback = new EnumThreadDelegate(WApi.ThreadWindows2);
             foreach (ProcessThread thread in Process.GetProcessById((int)pid).Threads)
             {
                 EnumThreadWindows(thread.Id, callback, IntPtr.Zero);
                 if (InputData.Result != IntPtr.Zero) return InputData.Result;
             }
         }
     }
     return InputData.Result;
 }
Exemplo n.º 11
0
 static extern bool EnumThreadWindows(int threadId, EnumThreadDelegate callback, IntPtr param);
Exemplo n.º 12
0
 private static extern bool EnumThreadWindows(int tid, EnumThreadDelegate callback, IntPtr lp);
Exemplo n.º 13
0
 public static extern bool EnumThreadWindows(uint threadId, EnumThreadDelegate threadFunc, IntPtr lParam);
Exemplo n.º 14
0
 public static extern bool EnumThreadWindows(int threadId, EnumThreadDelegate pfnEnum, IntPtr lParam);
Exemplo n.º 15
0
 static extern bool EnumThreadWindows(int dwThreadId, EnumThreadDelegate lpfn,
     IntPtr lParam);
Exemplo n.º 16
0
 public static extern bool EnumThreadWindows(int dwThreadId, EnumThreadDelegate lpfn, IntPtr lParam);
Exemplo n.º 17
0
 public static extern bool EnumThreadWindows(uint threadId, EnumThreadDelegate threadFunc, IntPtr lParam);