/// <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); }