Exemple #1
0
        /// <summary>
        /// Find and Push the OK button on the uninstall dialog.
        /// </summary>
        /// <param name="DisplayName">Display Name value from the registry</param>
        private static void PushUninstallOKButton(string DisplayName, Func <string, bool> log)
        {
            bool success = false;

            //Find the uninstall dialog.
            IntPtr uninstallerWin = FindUninstallerWindow(DisplayName, out success);
            IntPtr RemoveRadio    = IntPtr.Zero;
            IntPtr OKButton       = IntPtr.Zero;

            //If it found the window, look for the button.
            if (success)
            {
                RemoveRadio = FindUninstallerControl("Remove", uninstallerWin, out success, log);
            }
            if (success)
            {
                OKButton = FindUninstallerControl("&OK", uninstallerWin, out success, log);
            }

            //If it found the button, press it.
            if (success)
            {
                DeploymentUtilsWin32.DoButtonClick(RemoveRadio);
                DeploymentUtilsWin32.DoButtonClick(OKButton);
            }
        }
Exemple #2
0
        /// <summary>
        /// Find the uninstall dialog.
        /// </summary>
        /// <param name="DisplayName">Display Name retrieved from the registry.</param>
        /// <param name="success">Whether the window was found or not.</param>
        /// <returns>Pointer to the uninstall dialog.</returns>
        private static IntPtr FindUninstallerWindow(string DisplayName, out bool success)
        {
            //Max number of times to look for the window,
            //used to let you out if there's a problem.
            int i = 25;
            DeploymentUtilsWin32 w32 = new DeploymentUtilsWin32();
            IntPtr uninstallerWindow = IntPtr.Zero;

            while (uninstallerWindow == IntPtr.Zero && i > 0)
            {
                uninstallerWindow = w32.SearchForTopLevelWindow(DisplayName + " Maintenance");
                System.Threading.Thread.Sleep(500);
                i--;
            }

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

            return(uninstallerWindow);
        }
Exemple #3
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);
        }
Exemple #4
0
        public static bool FlashWindowAPI(IntPtr handleToWindow)
        {
            FLASHWINFO flashwinfo1 = new FLASHWINFO();

            flashwinfo1.cbSize    = (uint)Marshal.SizeOf(flashwinfo1);
            flashwinfo1.hwnd      = handleToWindow;
            flashwinfo1.dwFlags   = 15;
            flashwinfo1.uCount    = uint.MaxValue;
            flashwinfo1.dwTimeout = 0;
            return(DeploymentUtilsWin32.FlashWindowEx(ref flashwinfo1) == 0);
        }