예제 #1
0
        private static bool EnumTopWindows(IntPtr hWnd, IntPtr lParam)
        {
            int winProcessId = 0;

            WindowAction.GetWindowThreadProcessId(hWnd, out winProcessId);

            if (!IsWindow(hWnd) ||
                !WindowAction.IsWindowVisible(hWnd) ||
                hWnd == WindowAction.statusbar
                )
            {
                return(true);
            }

            GCHandle      gch = (GCHandle)lParam;
            ProcessHWinds phw = (ProcessHWinds)(gch.Target);

            if (!DoesWindowBelongToProcess(hWnd, phw.processId))
            {
                return(true);
            }

            phw.topWinds.Add(hWnd);

            return(true);
        }
예제 #2
0
        public static IntPtr[] GetTopWindowsForProcess(int processId)
        {
            ProcessHWinds phw      = new ProcessHWinds();
            ArrayList     topwinds = new ArrayList();

            phw.processId = processId;
            phw.topWinds  = topwinds;

            GCHandle gch = GCHandle.Alloc(phw);

            EnumWindowsProc callback = new EnumWindowsProc(EnumTopWindows);

            EnumWindows(callback, (IntPtr)gch);

            return((IntPtr[])topwinds.ToArray(typeof(IntPtr)));
        }