Example #1
0
        private IRegistryKey GetRCoreRegistryKeyWin32(StringBuilder logger)
        {
            CheckPlatformWin32();
            IRegistryKey rCore = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\R-core");

            if (rCore == null || rCore.GetRealKey() is null)
            {
                doLogSetEnvVarInfo(@"Local machine SOFTWARE\R-core not found - trying current user", logger);
                rCore = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\R-core");
                if (rCore == null || rCore.GetRealKey() is null)
                {
                    throw new ApplicationException("Windows Registry key 'SOFTWARE\\R-core' not found in HKEY_LOCAL_MACHINE nor HKEY_CURRENT_USER");
                }
            }
            doFoundWinRegKey(rCore, logger);
            bool is64Bit = Environment.Is64BitProcess;
            var  subKey  = is64Bit ? "R64" : "R";
            var  r       = rCore.OpenSubKey(subKey);

            if (r == null)
            {
                throw new ApplicationException(string.Format(
                                                   "Windows Registry sub-key '{0}' of key '{1}' was not found", subKey, rCore.ToString()));
            }
            doFoundWinRegKey(rCore, logger);
            return(r);
        }