示例#1
0
        /// <summary>
        /// Find the OK button on the uninstall dialog.
        /// </summary>
        /// <param name="UninstallerWindow">The pointer to the Uninstall Dialog</param>
        /// <param name="success">Whether it succeeded or not.</param>
        /// <returns>A pointer to the OK button</returns>
        private static IntPtr FindUninstallerControl(string caption, IntPtr UninstallerWindow, out bool success, Func <string, bool> log)
        {
            //max number of times to look for the button,
            //lets you out if there's a problem
            int i = 25;
            DeploymentUtilsWin32 w32 = new DeploymentUtilsWin32();
            IntPtr OKButton          = IntPtr.Zero;

            while (OKButton == IntPtr.Zero && i > 0)
            {
                OKButton = w32.SearchForChildWindow(UninstallerWindow, caption, log);
                System.Threading.Thread.Sleep(500);
                i--;
            }

            if (OKButton == IntPtr.Zero)
            {
                success = false;
            }
            else
            {
                success = true;
            }

            return(OKButton);
        }