Bloom.InstallerSupport.MakeBloomRegistryEntries C# (CSharp) Method

MakeBloomRegistryEntries() static private method

Make the registry entries Bloom requires. We do this every time a version of Bloom runs, so that if more than one is installed the latest wins.
static private MakeBloomRegistryEntries ( string programArgs ) : void
programArgs string
return void
        internal static void MakeBloomRegistryEntries(string[] programArgs)
        {
            if (Program.RunningUnitTests)
                return; // unit testing.
            // When installed in program files we only do registry entries when we are first installed,
            // thus keeping them consistent for all users, stored in HKLM.
            if (SharedByAllUsers() && !IsFirstTimeInstall(programArgs))
                return;
            _installInLocalMachine = SharedByAllUsers();
            if (Platform.IsLinux)
            {
                // This will be done by the package installer.
                return;
            }

            var iconDir = FileLocator.GetDirectoryDistributedWithApplication("icons");

            // This is what I (JohnT) think should make Bloom display the right icon for .BloomCollection files.
            EnsureRegistryValue(@".BloomCollection\DefaultIcon", Path.Combine(iconDir, "BloomCollectionIcon.ico"));
            EnsureRegistryValue(@".BloomPack\DefaultIcon", Path.Combine(iconDir, "BloomPack.ico"));

            // These may also be connected with making BloomCollection files display the correct icon.
            // Based on things found in (or done by) the old wix installer.
            EnsureRegistryValue(".BloomCollection", "Bloom.BloomCollectionFile");
            EnsureRegistryValue(".BloomCollectionFile", "Bloom.BloomCollectionFile");
            EnsureRegistryValue("Bloom.BloomCollectionFile", "Bloom Book Collection");
            EnsureRegistryValue(@"Bloom.BloomCollectionFile\DefaultIcon", Path.Combine(iconDir, "BloomCollectionIcon.ico, 0"));

            // I think these help BloomPack files display the correct icon.
            EnsureRegistryValue(".BloomPack", "Bloom.BloomPackFile");
            EnsureRegistryValue("Bloom.BloomPackFile", "Bloom Book Collection");
            EnsureRegistryValue(".BloomPackFile", "Bloom Book Collection");
            EnsureRegistryValue(@"Bloom.BloomPackFile\DefaultIcon", Path.Combine(iconDir, "BloomPack.ico, 0"));
            EnsureRegistryValue(@".BloomPackFile\DefaultIcon", Path.Combine(iconDir, "BloomPack.ico, 0"));
            EnsureRegistryValue(@"SOFTWARE\Classes\Bloom.BloomPack", "Bloom Book Pack", "FriendlyTypeName");

            // This might be part of registering as the executable for various file types?
            // I don't know what does it in wix but it's one of the things the old wix installer created.
            var exe = Assembly.GetExecutingAssembly().Location;
            EnsureRegistryValue(@"bloom\shell\open\command", "\"" + exe + "\" \"%1\"");

            BeTheExecutableFor(".BloomCollection", "BloomCollection file");
            BeTheExecutableFor(".BloomPack", "BloomPack file");
            // Make the OS run Bloom when it sees bloom://somebooktodownload
            BookDownloadSupport.RegisterForBloomUrlProtocol(_installInLocalMachine);
        }