diff options
Diffstat (limited to '')
| -rw-r--r-- | src/test/burn/WixTestTools/BundleRegistration.cs | 121 |
1 files changed, 17 insertions, 104 deletions
diff --git a/src/test/burn/WixTestTools/BundleRegistration.cs b/src/test/burn/WixTestTools/BundleRegistration.cs index 3541e7ea..524d4616 100644 --- a/src/test/burn/WixTestTools/BundleRegistration.cs +++ b/src/test/burn/WixTestTools/BundleRegistration.cs | |||
| @@ -5,108 +5,51 @@ namespace WixTestTools | |||
| 5 | using System; | 5 | using System; |
| 6 | using Microsoft.Win32; | 6 | using Microsoft.Win32; |
| 7 | 7 | ||
| 8 | public class BundleRegistration | 8 | public class BundleRegistration : GenericArpRegistration |
| 9 | { | 9 | { |
| 10 | public const string BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; | ||
| 11 | public const string BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY_WOW6432NODE = "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; | ||
| 12 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_CACHE_PATH = "BundleCachePath"; | ||
| 13 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_ADDON_CODE = "BundleAddonCode"; | 10 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_ADDON_CODE = "BundleAddonCode"; |
| 11 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_CACHE_PATH = "BundleCachePath"; | ||
| 14 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_DETECT_CODE = "BundleDetectCode"; | 12 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_DETECT_CODE = "BundleDetectCode"; |
| 15 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_PATCH_CODE = "BundlePatchCode"; | 13 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_PATCH_CODE = "BundlePatchCode"; |
| 14 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_PROVIDER_KEY = "BundleProviderKey"; | ||
| 15 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_RESUME_COMMAND_LINE = "BundleResumeCommandLine"; | ||
| 16 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_TAG = "BundleTag"; | ||
| 16 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_UPGRADE_CODE = "BundleUpgradeCode"; | 17 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_UPGRADE_CODE = "BundleUpgradeCode"; |
| 17 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_DISPLAY_NAME = "DisplayName"; | ||
| 18 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_VERSION = "BundleVersion"; | 18 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_VERSION = "BundleVersion"; |
| 19 | public const string BURN_REGISTRATION_REGISTRY_ENGINE_VERSION = "EngineVersion"; | 19 | public const string BURN_REGISTRATION_REGISTRY_ENGINE_VERSION = "EngineVersion"; |
| 20 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_PROVIDER_KEY = "BundleProviderKey"; | ||
| 21 | public const string BURN_REGISTRATION_REGISTRY_BUNDLE_TAG = "BundleTag"; | ||
| 22 | public const string REGISTRY_REBOOT_PENDING_FORMAT = "{0}.RebootRequired"; | ||
| 23 | public const string REGISTRY_BUNDLE_INSTALLED = "Installed"; | ||
| 24 | public const string REGISTRY_BUNDLE_DISPLAY_ICON = "DisplayIcon"; | ||
| 25 | public const string REGISTRY_BUNDLE_DISPLAY_VERSION = "DisplayVersion"; | ||
| 26 | public const string REGISTRY_BUNDLE_ESTIMATED_SIZE = "EstimatedSize"; | ||
| 27 | public const string REGISTRY_BUNDLE_PUBLISHER = "Publisher"; | ||
| 28 | public const string REGISTRY_BUNDLE_HELP_LINK = "HelpLink"; | ||
| 29 | public const string REGISTRY_BUNDLE_HELP_TELEPHONE = "HelpTelephone"; | ||
| 30 | public const string REGISTRY_BUNDLE_URL_INFO_ABOUT = "URLInfoAbout"; | ||
| 31 | public const string REGISTRY_BUNDLE_URL_UPDATE_INFO = "URLUpdateInfo"; | ||
| 32 | public const string REGISTRY_BUNDLE_PARENT_DISPLAY_NAME = "ParentDisplayName"; | ||
| 33 | public const string REGISTRY_BUNDLE_PARENT_KEY_NAME = "ParentKeyName"; | ||
| 34 | public const string REGISTRY_BUNDLE_COMMENTS = "Comments"; | ||
| 35 | public const string REGISTRY_BUNDLE_CONTACT = "Contact"; | ||
| 36 | public const string REGISTRY_BUNDLE_NO_MODIFY = "NoModify"; | ||
| 37 | public const string REGISTRY_BUNDLE_MODIFY_PATH = "ModifyPath"; | ||
| 38 | public const string REGISTRY_BUNDLE_NO_ELEVATE_ON_MODIFY = "NoElevateOnModify"; | ||
| 39 | public const string REGISTRY_BUNDLE_NO_REMOVE = "NoRemove"; | ||
| 40 | public const string REGISTRY_BUNDLE_SYSTEM_COMPONENT = "SystemComponent"; | ||
| 41 | public const string REGISTRY_BUNDLE_QUIET_UNINSTALL_STRING = "QuietUninstallString"; | ||
| 42 | public const string REGISTRY_BUNDLE_UNINSTALL_STRING = "UninstallString"; | ||
| 43 | public const string REGISTRY_BUNDLE_RESUME_COMMAND_LINE = "BundleResumeCommandLine"; | ||
| 44 | public const string REGISTRY_BUNDLE_VERSION_MAJOR = "VersionMajor"; | ||
| 45 | public const string REGISTRY_BUNDLE_VERSION_MINOR = "VersionMinor"; | ||
| 46 | 20 | ||
| 47 | public string[] AddonCodes { get; set; } | 21 | public string[] AddonCodes { get; set; } |
| 48 | 22 | ||
| 49 | public string CachePath { get; set; } | 23 | public string BundleVersion { get; set; } |
| 50 | 24 | ||
| 51 | public string DisplayName { get; set; } | 25 | public string CachePath { get; set; } |
| 52 | 26 | ||
| 53 | public string[] DetectCodes { get; set; } | 27 | public string[] DetectCodes { get; set; } |
| 54 | 28 | ||
| 55 | public string EngineVersion { get; set; } | 29 | public string EngineVersion { get; set; } |
| 56 | 30 | ||
| 57 | public int? EstimatedSize { get; set; } | ||
| 58 | |||
| 59 | public int? Installed { get; set; } | ||
| 60 | |||
| 61 | public string ModifyPath { get; set; } | ||
| 62 | |||
| 63 | public string[] PatchCodes { get; set; } | 31 | public string[] PatchCodes { get; set; } |
| 64 | 32 | ||
| 65 | public string ProviderKey { get; set; } | 33 | public string ProviderKey { get; set; } |
| 66 | 34 | ||
| 67 | public string Publisher { get; set; } | ||
| 68 | |||
| 69 | public int? SystemComponent { get; set; } | ||
| 70 | |||
| 71 | public string QuietUninstallString { get; set; } | ||
| 72 | |||
| 73 | public string QuietUninstallCommand { get; set; } | ||
| 74 | |||
| 75 | public string QuietUninstallCommandArguments { get; set; } | ||
| 76 | |||
| 77 | public string Tag { get; set; } | 35 | public string Tag { get; set; } |
| 78 | 36 | ||
| 79 | public string UninstallCommand { get; set; } | ||
| 80 | |||
| 81 | public string UninstallCommandArguments { get; set; } | ||
| 82 | |||
| 83 | public string UninstallString { get; set; } | ||
| 84 | |||
| 85 | public string[] UpgradeCodes { get; set; } | 37 | public string[] UpgradeCodes { get; set; } |
| 86 | 38 | ||
| 87 | public string UrlInfoAbout { get; set; } | 39 | public static bool TryGetPerMachineBundleRegistrationById(string id, bool x64, out BundleRegistration registration) |
| 88 | 40 | { | |
| 89 | public string UrlUpdateInfo { get; set; } | 41 | return TryGetRegistrationById(id, x64, false, out registration); |
| 90 | 42 | } | |
| 91 | public string Version { get; set; } | ||
| 92 | 43 | ||
| 93 | public static bool TryGetPerMachineBundleRegistrationById(string bundleId, bool x64, out BundleRegistration registration) | 44 | public static bool TryGetPerUserBundleRegistrationById(string id, out BundleRegistration registration) |
| 94 | { | 45 | { |
| 95 | var baseKeyPath = x64 ? BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY : BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY_WOW6432NODE; | 46 | return TryGetRegistrationById(id, true, true, out registration); |
| 96 | var registrationKeyPath = $"{baseKeyPath}\\{bundleId}"; | ||
| 97 | using var registrationKey = Registry.LocalMachine.OpenSubKey(registrationKeyPath); | ||
| 98 | var success = registrationKey != null; | ||
| 99 | registration = success ? GetBundleRegistration(registrationKey) : null; | ||
| 100 | return success; | ||
| 101 | } | 47 | } |
| 102 | 48 | ||
| 103 | public static bool TryGetPerUserBundleRegistrationById(string bundleId, out BundleRegistration registration) | 49 | private static bool TryGetRegistrationById(string id, bool x64, bool perUser, out BundleRegistration registration) |
| 104 | { | 50 | { |
| 105 | var registrationKeyPath = $"{BURN_REGISTRATION_REGISTRY_UNINSTALL_KEY}\\{bundleId}"; | 51 | registration = GetGenericArpRegistration(id, x64, perUser, key => GetBundleRegistration(key)); |
| 106 | using var registrationKey = Registry.CurrentUser.OpenSubKey(registrationKeyPath); | 52 | return registration != null; |
| 107 | var success = registrationKey != null; | ||
| 108 | registration = success ? GetBundleRegistration(registrationKey) : null; | ||
| 109 | return success; | ||
| 110 | } | 53 | } |
| 111 | 54 | ||
| 112 | private static BundleRegistration GetBundleRegistration(RegistryKey idKey) | 55 | private static BundleRegistration GetBundleRegistration(RegistryKey idKey) |
| @@ -120,38 +63,8 @@ namespace WixTestTools | |||
| 120 | registration.ProviderKey = idKey.GetValue(BURN_REGISTRATION_REGISTRY_BUNDLE_PROVIDER_KEY) as string; | 63 | registration.ProviderKey = idKey.GetValue(BURN_REGISTRATION_REGISTRY_BUNDLE_PROVIDER_KEY) as string; |
| 121 | registration.Tag = idKey.GetValue(BURN_REGISTRATION_REGISTRY_BUNDLE_TAG) as string; | 64 | registration.Tag = idKey.GetValue(BURN_REGISTRATION_REGISTRY_BUNDLE_TAG) as string; |
| 122 | registration.UpgradeCodes = idKey.GetValue(BURN_REGISTRATION_REGISTRY_BUNDLE_UPGRADE_CODE) as string[]; | 65 | registration.UpgradeCodes = idKey.GetValue(BURN_REGISTRATION_REGISTRY_BUNDLE_UPGRADE_CODE) as string[]; |
| 123 | registration.Version = idKey.GetValue(BURN_REGISTRATION_REGISTRY_BUNDLE_VERSION) as string; | 66 | registration.BundleVersion = idKey.GetValue(BURN_REGISTRATION_REGISTRY_BUNDLE_VERSION) as string; |
| 124 | registration.DisplayName = idKey.GetValue(BURN_REGISTRATION_REGISTRY_BUNDLE_DISPLAY_NAME) as string; | ||
| 125 | registration.EngineVersion = idKey.GetValue(BURN_REGISTRATION_REGISTRY_ENGINE_VERSION) as string; | 67 | registration.EngineVersion = idKey.GetValue(BURN_REGISTRATION_REGISTRY_ENGINE_VERSION) as string; |
| 126 | registration.EstimatedSize = idKey.GetValue(REGISTRY_BUNDLE_ESTIMATED_SIZE) as int?; | ||
| 127 | registration.Installed = idKey.GetValue(REGISTRY_BUNDLE_INSTALLED) as int?; | ||
| 128 | registration.ModifyPath = idKey.GetValue(REGISTRY_BUNDLE_MODIFY_PATH) as string; | ||
| 129 | registration.Publisher = idKey.GetValue(REGISTRY_BUNDLE_PUBLISHER) as string; | ||
| 130 | registration.SystemComponent = idKey.GetValue(REGISTRY_BUNDLE_SYSTEM_COMPONENT) as int?; | ||
| 131 | registration.UrlInfoAbout = idKey.GetValue(REGISTRY_BUNDLE_URL_INFO_ABOUT) as string; | ||
| 132 | registration.UrlUpdateInfo = idKey.GetValue(REGISTRY_BUNDLE_URL_UPDATE_INFO) as string; | ||
| 133 | |||
| 134 | registration.QuietUninstallString = idKey.GetValue(REGISTRY_BUNDLE_QUIET_UNINSTALL_STRING) as string; | ||
| 135 | if (!String.IsNullOrEmpty(registration.QuietUninstallString)) | ||
| 136 | { | ||
| 137 | var closeQuote = registration.QuietUninstallString.IndexOf("\"", 1); | ||
| 138 | if (closeQuote > 0) | ||
| 139 | { | ||
| 140 | registration.QuietUninstallCommand = registration.QuietUninstallString.Substring(1, closeQuote - 1).Trim(); | ||
| 141 | registration.QuietUninstallCommandArguments = registration.QuietUninstallString.Substring(closeQuote + 1).Trim(); | ||
| 142 | } | ||
| 143 | } | ||
| 144 | |||
| 145 | registration.UninstallString = idKey.GetValue(REGISTRY_BUNDLE_UNINSTALL_STRING) as string; | ||
| 146 | if (!String.IsNullOrEmpty(registration.UninstallString)) | ||
| 147 | { | ||
| 148 | var closeQuote = registration.UninstallString.IndexOf("\"", 1); | ||
| 149 | if (closeQuote > 0) | ||
| 150 | { | ||
| 151 | registration.UninstallCommand = registration.UninstallString.Substring(1, closeQuote - 1).Trim(); | ||
| 152 | registration.UninstallCommandArguments = registration.UninstallString.Substring(closeQuote + 1).Trim(); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | 68 | ||
| 156 | return registration; | 69 | return registration; |
| 157 | } | 70 | } |
