Ejemplo n.º 1
0
        public static WindowModel FindWindowStartsWith(string lpClassName, string lpWindowName, bool IsSelfProcessId = true)
        {
            WindowModel wm = WindowModel.Empty;
            var         ca = IntPtr.Zero;

            while (true)
            {
                var ip = User32Api.FindWindowEx(IntPtr.Zero, ca, lpClassName, null);
                if (ip != IntPtr.Zero)
                {
                    wm = new WindowModel(ip);
                    if (IsSelfProcessId && wm.ProcessId != ProcessId)
                    {
                        ca = ip;
                        continue;
                    }
                    if (wm.Title.StartsWith(lpWindowName))
                    {
                        return(wm);
                    }
                    else
                    {
                        ca = ip;
                    }
                }
                return(WindowModel.Empty);
            }
        }