private void PerformRegistration(string packageId, string fileSystemRoot, INiPackage package) { var registrationContext = new NiRegistrationContext(Context, packageId, fileSystemRoot); // Unregister when this package is already installed. bool isInstalled; using (var rootKey = OpenContextRegistry(false)) using (var packageKey = rootKey.OpenSubKey("InstalledProducts\\" + packageId)) { isInstalled = packageKey != null; } if (isInstalled) { Marshal.ThrowExceptionForHR((int)package.Unregister(registrationContext)); } // Perform the registration process. Marshal.ThrowExceptionForHR((int)package.Register(registrationContext)); }
private void PerformRegistration(string packageId, string fileSystemRoot, INiPackage package) { var registrationContext = new NiRegistrationContext(Context, packageId, fileSystemRoot); // Unregister when this package is already installed. bool isInstalled; using (var rootKey = OpenContextRegistry(false)) using (var packageKey = rootKey.OpenSubKey("InstalledProducts\\" + packageId)) { isInstalled = packageKey != null; } if (isInstalled) Marshal.ThrowExceptionForHR((int)package.Unregister(registrationContext)); // Perform the registration process. Marshal.ThrowExceptionForHR((int)package.Register(registrationContext)); }
private bool PerformUnregistration(string fileSystemRoot, INiPackage package) { // Unregister when this package is already installed. using (var contextKey = OpenContextRegistry(false)) using (var key = contextKey.OpenSubKey("InstalledProducts\\" + _packageId)) { if (key == null) return false; } var registrationContext = new NiRegistrationContext(Context, _packageId, fileSystemRoot); Marshal.ThrowExceptionForHR((int)package.Unregister(registrationContext)); return true; }