示例#1
0
        /// <summary>
        /// レジストリ情報を読み込む
        /// </summary>
        private void LoadRegistry()
        {
            InternalHostsSaveTarget = RegistryUtility.StrRegistryReadValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrInternalHostsTargetRegistryName);
            ExternalHostsSaveTarget = RegistryUtility.StrRegistryReadValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrExternalHostsTargetRegistryName);

            NetworkAuthenticationUsername = RegistryUtility.StrRegistryReadValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrNetworkAuthenticationUsernameName);

            int value = 0;

            if (RegistryUtility.FRegistryReadDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsApplyInExternalHostsRegistryName, out value) == true)
            {
                IsApplyInExternalHosts = (value == 0) ? false : true;
            }

            if (RegistryUtility.FRegistryReadDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsUpdateInternalHostsRegistryName, out value) == true)
            {
                IsUpdateInternalHosts = (value == 0) ? false : true;
            }

            if (RegistryUtility.FRegistryReadDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsNetworkAuthenticationName, out value) == true)
            {
                IsNetworkAuthentication = (value == 0) ? false : true;
            }

            internalHostsPathTextBox.Text                     = InternalHostsSaveTarget;
            externalHostsPathTextBox.Text                     = ExternalHostsSaveTarget;
            networkAuthenticationUsernameTextBox.Text         = NetworkAuthenticationUsername;
            networkAuthenticationPasswordPasswordBox.Password = CryptUtility.DecryptString(RegistryUtility.RGBRegistryReadBinaryValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrNetworkAuthenticationPasswordName));
            internalHostsPathCheckBox.IsChecked               = IsUpdateInternalHosts;
            externalHostsPathCheckBox.IsChecked               = IsApplyInExternalHosts;
            networkAuthenticationCheckBox.IsChecked           = IsNetworkAuthentication;
        }
示例#2
0
        private void CheckedLanguageCommandExecute(object e)
        {
            var commandParam = (string)((e as EkushApp.ShellService.Commands.EventToCommandArgs).CommandParameter);

            LocaleManager.SetCurrentLanguage(commandParam);
            RegistryUtility.WriteRegistryKey(Globals.RegistryConstants.KEY_PATH, Globals.RegistryConstants.LOCALE_KEY_NAME, commandParam);
        }
        private static void InitCommand()
        {
            // Check if project file already exists
            string path = Environment.CurrentDirectory;

            if (ProjectUtility.ProjectExists(path))
            {
                Console.Error.WriteLine("A Hephaestus project is already initialized. Use 'hephaestus' to launch Hephaestus.");

                Environment.Exit(1);
            }

            if (ConsoleUtility.AskYesNoQuestion("Use the command line?"))
            {
                InitFromCommandLineCommand();
                return;
            }

            // Launch Hephaestus Configurator
            ProcessStartInfo processStartInfo = new ProcessStartInfo
            {
                Arguments = path,
                // TODO: Create key in HephaestusInstaller
                FileName = RegistryUtility.GetKey(@"SOFTWARE\WOW6432Node\ArmaAchilles\Hephaestus\HephaestusConfigurator", "Path")
            };

            Process.Start(processStartInfo);

            Environment.Exit(0);
        }
示例#4
0
        /// <summary>
        /// Registers file extension mapping.
        /// </summary>
        /// <param name="fileExtension">The file extension to register.</param>
        /// <param name="overrideIfExist">true if override the existed one; otherwise, false.</param>
        /// <returns>true if registers succeeded; otherwise, false.</returns>
        public static bool RegisterFileExtensionMapping(string fileExtension, bool overrideIfExist = false)
        {
            if (!overrideIfExist && FileExtensionMapping.ContainsKey(fileExtension))
            {
                return(false);
            }
            var    r = GetRegistryKeyByFileExtension(fileExtension, false);
            string v;

            if (r != null)
            {
                v = RegistryUtility.TryGetStringValue(r, "Content Type");
                if (string.IsNullOrWhiteSpace(v))
                {
                    return(false);
                }
                return(FileExtensionMapping.Set(fileExtension, v, overrideIfExist));
            }

            if (fileExtension.IndexOf('/') < 1)
            {
                return(false);
            }
            v = fileExtension;
            using var mime = RegistryUtility.TryOpenSubKey(Reg.ClassesRoot, "MIME\\Database\\Content Type\\" + fileExtension);
            fileExtension  = RegistryUtility.TryGetStringValue(mime, "Extension");
            return(FileExtensionMapping.Set(fileExtension, v, overrideIfExist));
        }
示例#5
0
        public void ReadFromRegistry(string registrySubKey)
        {
            RegistryUtility regUtil = new RegistryUtility(registrySubKey + "\\" + this.InstanceNumber.ToString("00"));

            foreach (var prop in this.GetType().GetProperties())
            {
                string strValue = regUtil.Read(prop.Name).ToString();

                if (prop.PropertyType == typeof(Int32))
                {
                    int intVal = int.Parse(strValue);
                    prop.SetValue(this, intVal, null);
                }
                else if (prop.PropertyType == typeof(DatabaseTypes))
                {
                    DatabaseTypes dbType = (DatabaseTypes)Enum.Parse(typeof(DatabaseTypes), strValue);
                    prop.SetValue(this, dbType, null);
                }
                else if (prop.PropertyType == typeof(SourceLevels))
                {
                    SourceLevels level = (SourceLevels)Enum.Parse(typeof(SourceLevels), strValue);
                    prop.SetValue(this, level, null);
                }
                else if (prop.PropertyType == typeof(bool))
                {
                    bool boolValue = bool.Parse(strValue);
                    prop.SetValue(this, boolValue, null);
                }
                else
                {
                    prop.SetValue(this, strValue, null);
                }
            }
        }
        /// <summary>
        /// レジストリ情報を読み込む
        /// </summary>
        private void LoadRegistry()
        {
            string strInternalHostsSaveTarget = RegistryUtility.StrRegistryReadValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrInternalHostsTargetRegistryName);
            string strExternalHostsSaveTarget = RegistryUtility.StrRegistryReadValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrExternalHostsTargetRegistryName);

            internalHostsSaveTargetCollection = strInternalHostsSaveTarget.Split(new char[] { ';' }).Select(x => x.Trim()).Where(x => !string.IsNullOrWhiteSpace(x));
            externalHostsSaveTargetCollection = strExternalHostsSaveTarget.Split(new char[] { ';' }).Select(x => x.Trim()).Where(x => !string.IsNullOrWhiteSpace(x));

            NetworkAuthenticationUsername = RegistryUtility.StrRegistryReadValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrNetworkAuthenticationUsernameName);
            NetworkAuthenticationPassword = CryptUtility.DecryptString(RegistryUtility.RGBRegistryReadBinaryValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrNetworkAuthenticationPasswordName));

            int value = 0;

            if (RegistryUtility.FRegistryReadDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsApplyInExternalHostsRegistryName, out value) == true)
            {
                IsApplyInExternalHosts = (value == 0) ? false : true;
            }

            if (RegistryUtility.FRegistryReadDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsUpdateInternalHostsRegistryName, out value) == true)
            {
                IsUpdateInternalHosts = (value == 0) ? false : true;
            }

            if (RegistryUtility.FRegistryReadDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsNetworkAuthenticationName, out value) == true)
            {
                IsNetworkAuthentication = (value == 0) ? false : true;
            }
        }
示例#7
0
 private void OnCSVFileAssociationToolsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(CSVEditor.Properties.Resources.CSVFileAssociationToolsHint + "\n" + CSVEditor.Properties.Resources.ConfirmThisOperation
                         , "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         RegistryUtility.SetRegisterFileExtendWithThisApp(".csv", "CSVEditor.CSV", "CSVEditor的csv文件", "在CSVEditor中打开");
     }
 }
示例#8
0
        public void WriteToRegistry(string registrySubKey)
        {
            RegistryUtility regUtil = new RegistryUtility(registrySubKey + "\\" + this.InstanceNumber.ToString("00"));

            foreach (var prop in this.GetType().GetProperties())
            {
                regUtil.Write(prop.Name, prop.GetValue(this, null));
            }
        }
示例#9
0
        /// <summary>
        /// Writes the data into registry.
        /// </summary>
        /// <param name="card">The card.</param>
        public static void WriteDataIntoRegistry(WindowsNetworkCard card)
        {
            RegistryKey regKey = null;

            string sKey = @"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" + card.Id;

            try
            {
                regKey = Registry.LocalMachine.OpenSubKey(sKey);

                RegistryUtility.WriteIntValue(RegistryKeyType.LocalMachine, sKey, "EnableDhcp", card.Dhcp ? 1 : 0);

                if (card.Dhcp)
                {
                    String[] temp = { "0.0.0.0" };
                    RegistryUtility.WriteMultiStringValue(RegistryKeyType.LocalMachine, sKey, "IPAddress", temp);
                    RegistryUtility.WriteMultiStringValue(RegistryKeyType.LocalMachine, sKey, "SubnetMask", temp);

                    temp[0] = "";
                    RegistryUtility.WriteMultiStringValue(RegistryKeyType.LocalMachine, sKey, "DefaultGateway", temp);
                }
                else
                {
                    String[] temp = { "0.0.0.0" };

                    temp[0] = card.IpAddress;
                    RegistryUtility.WriteMultiStringValue(RegistryKeyType.LocalMachine, sKey, "IPAddress", temp);
                    temp[0] = card.SubnetMask;
                    RegistryUtility.WriteMultiStringValue(RegistryKeyType.LocalMachine, sKey, "SubnetMask", temp);
                    temp[0] = card.GatewayAddress;
                    RegistryUtility.WriteMultiStringValue(RegistryKeyType.LocalMachine, sKey, "DefaultGateway", temp);
                }

                string dns = "";
                if (!card.DynamicDNS)
                {
                    if (card.Dns.Length >= 1)
                    {
                        dns = card.Dns;
                    }
                    if (card.Dns2.Length >= 1)
                    {
                        dns += "," + card.Dns2;
                    }
                }
                RegistryUtility.WriteStringValue(RegistryKeyType.LocalMachine, sKey, "NameServer", dns);
            }
            finally
            {
                if (regKey != null)
                {
                    regKey.Close();
                }
            }
        }
示例#10
0
        /// <summary>
        /// Determines whether [is network card in registry] [the specified card].
        /// </summary>
        /// <param name="card">The card.</param>
        /// <returns>
        ///   <c>true</c> if [is network card in registry] [the specified card]; otherwise, <c>false</c>.
        /// </returns>
        internal static Boolean IsNetworkCardInRegistry(WindowsNetworkCard card)
        {
            if (String.IsNullOrEmpty(card.Id))
            {
                return(false);
            }

            string sKey = @"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" + card.Id;

            return(RegistryUtility.Exists(RegistryKeyType.LocalMachine, sKey));
        }
示例#11
0
    /// <summary>
    /// 初始化数据
    /// </summary>
    public Setting()
    {
        FirstRun = true;

        BeyondCompareAutoExePath = true;
        BeyondCompareExePath     = "";
        CodeCompareAutoExePath   = true;
        CodeCompareExePath       = "";

        RegistryUtility.SetRegisterFileExtendWithThisApp(".csv", "CsvEditor.CSV", "CsvEditor的csv文件", "在CsvEditor中打开");
    }
示例#12
0
        public string GetVersionFromRegistry()
        {
            var registryUtility = new RegistryUtility(registryLlvmUninstall);
            var version         = registryUtility.ReadLocalMachineKey(keyDisplayVersion);

            if (version == null)
            {
                return(string.Empty);
            }

            return(version);
        }
示例#13
0
        public string GetLlvmPathFromRegistry()
        {
            var registryUtility = new RegistryUtility(registryLlvm);
            var path            = registryUtility.ReadLocalMachineKey(keyInstallPath);

            if (path == null)
            {
                return(string.Empty);
            }

            return(Path.Combine(path, "bin"));
        }
示例#14
0
        public Prefecture(string id, string name, string redirectURL, IPrefectureRequestor requestor)
        {
            _id              = id;
            _name            = name;
            _redirectURL     = redirectURL;
            _requestor       = requestor;
            _requestor.Owner = this;

            _enabled = RegistryUtility.GetPrefectureQueryEnabled(_id);

            _queryTime         = PrefectureConfiguration.GetPrefectureQueryTime(_id);
            _secondsUntilQuery = 0;
        }
示例#15
0
        /// <summary>
        /// Maps the data from registry.
        /// </summary>
        /// <param name="card">The card.</param>
        internal static void MapDataFromRegistry(WindowsNetworkCard card)
        {
            RegistryKey regKey = null;

            string sKey = @"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" + card.Id;

            try
            {
                regKey              = Registry.LocalMachine.OpenSubKey(sKey);
                card.IpAddress      = RegistryUtility.ReadStringValue(RegistryKeyType.LocalMachine, sKey, "IPAddress");
                card.GatewayAddress = RegistryUtility.ReadStringValue(RegistryKeyType.LocalMachine, sKey, "DefaultGateway");
                card.SubnetMask     = RegistryUtility.ReadStringValue(RegistryKeyType.LocalMachine, sKey, "SubnetMask");

                card.Dhcp = RegistryUtility.ReadIntValue(RegistryKeyType.LocalMachine, sKey, "EnableDhcp") == 1 ? true : false;

                string[] dns = RegistryUtility.ReadStringValue(RegistryKeyType.LocalMachine, sKey, "NameServer").Split(',');

                if (dns.Length >= 1)
                {
                    card.Dns = dns[0];
                }
                if (dns.Length >= 2)
                {
                    card.Dns2 = dns[1];
                }

                card.CurrentIpAddress      = RegistryUtility.ReadStringValue(RegistryKeyType.LocalMachine, sKey, "DhcpIPAddress");
                card.CurrentGatewayAddress = RegistryUtility.ReadStringValue(RegistryKeyType.LocalMachine, sKey, "DhcpDefaultGateway");
                card.CurrentSubnetMask     = RegistryUtility.ReadStringValue(RegistryKeyType.LocalMachine, sKey, "DhcpSubnetMask");

                string[] cdns = RegistryUtility.ReadStringValue(RegistryKeyType.LocalMachine, sKey, "DhcpServer").Split(' ');

                if (cdns.Length >= 1)
                {
                    card.CurrentDns = cdns[0];
                }
                if (cdns.Length >= 2)
                {
                    card.CurrentDns2 = cdns[1];
                }
            }
            finally
            {
                if (regKey != null)
                {
                    regKey.Close();
                }
            }
        }
示例#16
0
        public static void Attach(IWorkbench workbench)
        {
            WorkbenchSingleton.workbench = workbench;

            Form form = workbench as Form;

            form.Location    = new Point((int)RegistryUtility.GetValue("X", 100), (int)RegistryUtility.GetValue("Y", 100));
            form.Size        = new Size((int)RegistryUtility.GetValue("Width", 800), (int)RegistryUtility.GetValue("Height", 600));
            form.WindowState = GetWindowState((string)RegistryUtility.GetValue("WindowState", "Normal"));
            form.Closed     += delegate {
                RegistryUtility.SetValue("X", form.Location.X);
                RegistryUtility.SetValue("Y", form.Location.Y);
                RegistryUtility.SetValue("Width", form.Size.Width);
                RegistryUtility.SetValue("Height", form.Size.Height);
                RegistryUtility.SetValue("WindowState", form.WindowState);
            };
        }
示例#17
0
        /// <summary>
        /// Шифрует массив байт
        /// </summary>
        /// <param name="originalData">Массив байт для шифрации</param>
        /// <returns>Зашифрованный массив байт</returns>
        public static byte[] RSAEncrypt(byte[] originalData)
        {
            try
            {
                byte[] keyData = _rsa.ExportCspBlob(true);

                RegistryUtility.SetBinaryValue("CSPBlob", SystemConfiguration.CommonRegKey, (object)keyData, RegistryValueKind.Binary);

                return(_rsa.Encrypt(originalData, false));
            }
            catch (CryptographicException e)
            {
                DebugHelper.WriteLogEntry(e.ToString());

                return(null);
            }
        }
示例#18
0
        private void SaveRegistryFromXmlResources(XmlResources xmlResources)
        {
            // ExternalHostsTarget
            RegistryUtility.FRegistrySetValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrExternalHostsTargetRegistryName, xmlResources.ExternalHostsTarget);
            // InternalHostsTarget
            RegistryUtility.FRegistrySetValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrInternalHostsTargetRegistryName, xmlResources.InternalHostsTarget);
            // ApplyInExternalHosts (Enabled)

            RegistryUtility.FRegistrySetDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsApplyInExternalHostsRegistryName, (uint)xmlResources.ApplyInExternalHosts);
            // UpdateInternalHosts (Enabled)
            RegistryUtility.FRegistrySetDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsUpdateInternalHostsRegistryName, (uint)xmlResources.UpdateInternalHosts);
            // NetworkAuthentication (Disabled)
            RegistryUtility.FRegistrySetDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsNetworkAuthenticationName, (uint)xmlResources.NetworkAuthentication);
            // NetworkAuthenticationUsername (Empty)
            RegistryUtility.FRegistrySetValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrNetworkAuthenticationUsernameName, xmlResources.NetworkUsername);
            // NetworkAuthenticationPassword (Empty)
            RegistryUtility.FRegistrySetBinaryValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrNetworkAuthenticationPasswordName, xmlResources.NetworkPassword);
        }
示例#19
0
        /// <summary>
        /// 現在の設定をレジストリに保存する
        /// </summary>
        private void SaveRegistry()
        {
            // ExternalHostsTarget
            RegistryUtility.FRegistrySetValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrExternalHostsTargetRegistryName, ExternalHostsSaveTarget);
            // InternalHostsTarget
            RegistryUtility.FRegistrySetValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrInternalHostsTargetRegistryName, InternalHostsSaveTarget);
            // ApplyInExternalHosts (Enabled)

            RegistryUtility.FRegistrySetDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsApplyInExternalHostsRegistryName, (IsApplyInExternalHosts) ? (uint)1 : (uint)0);
            // UpdateInternalHosts (Enabled)
            RegistryUtility.FRegistrySetDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsUpdateInternalHostsRegistryName, (IsUpdateInternalHosts) ? (uint)1 : (uint)0);
            // NetworkAuthentication (Disabled)
            RegistryUtility.FRegistrySetDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsNetworkAuthenticationName, (IsNetworkAuthentication) ? (uint)1 : (uint)0);
            // NetworkAuthenticationUsername (Empty)
            RegistryUtility.FRegistrySetValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrNetworkAuthenticationUsernameName, NetworkAuthenticationUsername);
            // NetworkAuthenticationPassword (Empty)
            RegistryUtility.FRegistrySetBinaryValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrNetworkAuthenticationPasswordName, CryptUtility.EncryptString(NetworkAuthenticationPassword));
        }
示例#20
0
    public override void AutoExePathToSetting()
    {
        if (!Setting.Instance.BeyondCompareAutoExePath)
        {
            return;
        }
        string exePath = (string)RegistryUtility.GetBaseSubKeyValue(RegistryHive.LocalMachine, RegistryView.Registry64, GlobalData.REGISTRY_KEY_BEYONDCOMPARE, "ExePath");

        if (string.IsNullOrEmpty(exePath))
        {
            exePath = "";
            if (Setting.Instance.FirstRun && MessageBox.Show("代码比较工具初始化失败,可能未正确安装BeyondCompare.\n是否打开官网下载工具?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                System.Diagnostics.Process.Start(BEYOND_COMPARE_URL);
            }
        }
        Setting.Instance.BeyondCompareExePath = exePath;
    }
示例#21
0
        private XmlResources LoadRegistryToXmlResources()
        {
            string internalHostsSaveTarget       = RegistryUtility.StrRegistryReadValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrInternalHostsTargetRegistryName);
            string externalHostsSaveTarget       = RegistryUtility.StrRegistryReadValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrExternalHostsTargetRegistryName);
            string networkAuthenticationUsername = RegistryUtility.StrRegistryReadValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrNetworkAuthenticationUsernameName);

            byte[] networkAuthenticationPassword = RegistryUtility.RGBRegistryReadBinaryValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrNetworkAuthenticationPasswordName);
            int    isUpdateInternalHosts         = 0;
            int    isApplyInExternalHosts        = 0;
            int    isNetworkAuthentication       = 0;

            RegistryUtility.FRegistryReadDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsUpdateInternalHostsRegistryName, out isUpdateInternalHosts);
            RegistryUtility.FRegistryReadDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsApplyInExternalHostsRegistryName, out isApplyInExternalHosts);
            RegistryUtility.FRegistryReadDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsNetworkAuthenticationName, out isNetworkAuthentication);

            XmlResources xmlResources = new XmlResources(internalHostsSaveTarget, externalHostsSaveTarget, isUpdateInternalHosts, isApplyInExternalHosts, isNetworkAuthentication, networkAuthenticationUsername, networkAuthenticationPassword);

            return(xmlResources);
        }
示例#22
0
        private void serviceInstaller_AfterInstall(object sender, InstallEventArgs e)
        {
            // Set default Registry value (InstallUtill)

            // ExternalHostsTarget
            RegistryUtility.FRegistrySetValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrExternalHostsTargetRegistryName, LocalResources.m_gstrExternalHostsTargetRegistryDefaultValue);
            // InternalHostsTarget
            RegistryUtility.FRegistrySetValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrInternalHostsTargetRegistryName, LocalResources.m_gstrInternalHostsTargetRegistryDefaultValue);
            // ApplyInExternalHosts (Enabled)
            RegistryUtility.FRegistrySetDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsApplyInExternalHostsRegistryName, LocalResources.m_gintDefaultEnabledValue);
            // UpdateInternalHosts (Enabled)
            RegistryUtility.FRegistrySetDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsUpdateInternalHostsRegistryName, LocalResources.m_gintDefaultEnabledValue);
            // NetworkAuthentication (Disabled)
            RegistryUtility.FRegistrySetDwordValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrIsNetworkAuthenticationName, LocalResources.m_gintDefaultDisabledValue);
            // NetworkAuthenticationUsername (Empty)
            RegistryUtility.FRegistrySetValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrNetworkAuthenticationUsernameName, String.Empty);
            // NetworkAuthenticationPassword (Empty)
            RegistryUtility.FRegistrySetValue(Microsoft.Win32.RegistryHive.LocalMachine, LocalResources.m_gstrAutoHostsUpdateServiceRegistryPath, LocalResources.m_gstrNetworkAuthenticationPasswordName, String.Empty);
        }
示例#23
0
        /// <summary>
        /// Reads the config.
        /// </summary>
        /// <returns></returns>
        public static ProxyConfiguration ReadConfig()
        {
            ProxyConfiguration ret = new ProxyConfiguration();

            long tmp1 = RegistryUtility.ReadIntValue(RegistryKeyType.CurrentUser, RK_INTERNET_SETTINGS, "ProxyEnable", 0);

            if (tmp1.Equals(1))
            {
                ret.Enabled = true;
            }
            else
            {
                ret.Enabled = false;
            }

            string tmp2 = RegistryUtility.ReadStringValue(RegistryKeyType.CurrentUser, RK_INTERNET_SETTINGS, "ProxyServer");

            string[] aTmp2 = tmp2.Split(':');
            ret.ServerAddress = aTmp2[0];
            if (aTmp2.Length > 1)
            {
                ret.Port = Int32.Parse(aTmp2[1]);
            }


            string tmp3 = RegistryUtility.ReadStringValue(RegistryKeyType.CurrentUser, RK_INTERNET_SETTINGS, "ProxyOverride");

            if (tmp3.EndsWith(";<local>"))
            {
                ret.ProxyOverrideEnabled = true;
                tmp3 = tmp3.Substring(0, tmp3.IndexOf(";<local>") - 1);
                ret.ProxyOverride = tmp3;
            }
            else
            {
                ret.ProxyOverrideEnabled = false;
                ret.ProxyOverride        = tmp3;
            }


            return(ret);
        }
示例#24
0
        /// <summary>
        /// Gets the MIME content type by file extension part.
        /// </summary>
        /// <param name="fileExtension">The file extension part.</param>
        /// <param name="throwExceptionForNullOrEmpty">true if throw an argument exception if the file extension is null or empty; otherwise, false.</param>
        /// <returns>The registry key.</returns>
        /// <exception cref="ArgumentNullException">fileExtension was null.</exception>
        /// <exception cref="ArgumentException">fileExtension was empty.</exception>
        private static RegistryKey GetRegistryKeyByFileExtension(string fileExtension, bool throwExceptionForNullOrEmpty)
        {
            if (fileExtension == null && throwExceptionForNullOrEmpty)
            {
                throw new ArgumentNullException(nameof(fileExtension), "fileExtension should not be null.");
            }
            fileExtension = fileExtension.Trim().ToLowerInvariant();
            if (fileExtension.Length < 1)
            {
                if (throwExceptionForNullOrEmpty)
                {
                    throw new ArgumentException("fileExtension should not be empty.", nameof(fileExtension));
                }
                return(null);
            }

            var r = RegistryUtility.TryOpenSubKey(Reg.ClassesRoot, fileExtension);

            return(r);
        }
        internal bool IsSlackInitialized()
        {
            string token = RegistryUtility.Read("MyToken");

            var init = Slack.Initialize(token);

            if (init == null)
            {
                throw new SlackApiException("Initialization failed.");
            }

            bool hasInitSuccess = init.IsSuccess;

            if (!hasInitSuccess)
            {
                throw new SlackApiException(init.Message);
            }

            return(true);
        }
        public static void Main(string[] args)
        {
            try
            {
                string token = RegistryUtility.Read("MyToken");

                var init = Slack.Initialize(token);
                if (init == null)
                {
                    throw new ArgumentNullException(nameof(init));
                }

                System.Console.WriteLine(init.Message);

                if (!init.IsSuccess)
                {
                    return;
                }

                var thread = new Thread(GetMessages);
                thread.Start();

                //var message = new Message
                //{
                //    ChannelId = "general",
                //    MessageText = "Testar om meddelande kommer fram."
                //};

                //Slack.SendMessage(message);
            }
            catch (Exception ex)
            {
                ExceptionLogging.Trace(ex);

                System.Console.WriteLine(ex.Message);

                System.Console.ReadLine();
            }
        }
示例#27
0
        /// <summary>
        /// Дешифрует массив байт
        /// </summary>
        /// <param name="encryptedData">Массив байт для дешифрации</param>
        /// <returns>Дешифрованный массив байт</returns>
        public static byte[] RSADecrypt(byte[] encryptedData)
        {
            try
            {
                byte[] keyData = (byte[])RegistryUtility.GetBinaryValue("CSPBlob", SystemConfiguration.CommonRegKey);

                if (keyData != null)
                {
                    _rsa.ImportCspBlob(keyData);
                }

                return(_rsa.Decrypt(encryptedData, false));
            }
            catch (CryptographicException e)
            {
                // перезапуск
                _rsa = new RSACryptoServiceProvider();

                DebugHelper.WriteLogEntry(e.ToString());

                return(null);
            }
        }
        private void ButtonSaveToken_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.TextBoxToken.Text))
            {
                MessageBox.Show("Please enter a token.");
            }

            string token = this.TextBoxToken.Text.Trim();

            RegistryUtility.Save("MyToken", token);

            var window = WindowHelper.GetWindowByClassName <Slack.Desktop.Application.MainWindow>();

            bool isInitilized = window.IsSlackInitialized();

            if (isInitilized)
            {
                window.NotificationArea.Children.Clear();

                window.UnSetColorsOnSlackSharpIcon();

                this.Close();
            }
        }
示例#29
0
        private void TryDeleteAllFiles()
        {
            try
            {
                if (null != _tempFilePath && File.Exists(_tempFilePath))
                {
                    File.Delete(_tempFilePath);
                }
            }
            catch (Exception exception)
            {
                Debug.Write(exception);
            }

            try
            {
                if (Directory.Exists(SetupConsts.AppDirectory))
                {
                    Directory.Delete(SetupConsts.AppDirectory, true);
                }
            }
            catch (Exception exception)
            {
                Debug.Write(exception);
            }

            ShortcutUtility.TryDeleteShortcut(
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu)),
                SetupConsts.AppStartupFile);

            ShortcutUtility.TryDeleteShortcut(
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)),
                SetupConsts.AppStartupFile);

            RegistryUtility.RemoveUninstallRegistryKey();
        }
示例#30
0
 public SettingsMover(IRegistry registryWrap, RegistryUtility registryUtility)
 {
     _registryWrap    = registryWrap;
     _registryUtility = registryUtility;
 }