Пример #1
0
            IntPtr _w, _wDesk;             //not wnd because then TypeLoadException

            public int IsShellWindow(wnd w)
            {
                if (w.Is0)
                {
                    return(0);
                }
                wnd wDesk = getwnd.shellWindow;                 //fast

                if (w == wDesk)
                {
                    return(1);                            //Progman. Other window (WorkerW) may be active when desktop active.
                }
                //cache because GetWindowThreadProcessId quite slow
                if (w.Handle != _w)
                {
                    _w = w.Handle; _tidW = w.GetThreadProcessId(out _pidW);
                }
                if (wDesk.Handle != _wDesk)
                {
                    _wDesk = wDesk.Handle; _tidD = wDesk.GetThreadProcessId(out _pidD);
                }

                if (_tidW == _tidD)
                {
                    return(1);
                }
                if (_pidW == _pidD)
                {
                    return(2);
                }
                return(0);
            }