private static void InternalSetAutoHideInTabletMode(bool hide) { //todo: is update needed here? if (IsAutoHideInTabletModeSupported) { RegistryUtil.SetValue(RegistryPath, AutoHideInTabletModeKey, hide ? 1 : 0); } }
public WindowsDefenderSettings(string defenderKeyPath, Runtime runtime) { var pathExclusionData = runtime.GetValues(RegistryHive.LocalMachine, $"{ defenderKeyPath}\\Exclusions\\Paths"); PathExclusions = new List <string>(); foreach (var kvp in pathExclusionData) { PathExclusions.Add(kvp.Key); } PolicyManagerPathExclusions = new List <string>(); var excludedPaths = runtime.GetStringValue(RegistryHive.LocalMachine, $"{defenderKeyPath}\\Policy Manager", "ExcludedPaths"); if (excludedPaths != null) { foreach (var s in excludedPaths.Split('|')) { PolicyManagerPathExclusions.Add(s); } } var processExclusionData = runtime.GetValues(RegistryHive.LocalMachine, $"{defenderKeyPath}\\Exclusions\\Processes"); ProcessExclusions = new List <string>(); foreach (var kvp in processExclusionData) { ProcessExclusions.Add(kvp.Key); } var extensionExclusionData = runtime.GetValues(RegistryHive.LocalMachine, $"{defenderKeyPath}\\Exclusions\\Extensions"); ExtensionExclusions = new List <string>(); foreach (var kvp in extensionExclusionData) { ExtensionExclusions.Add(kvp.Key); } var asrKeyPath = $"{defenderKeyPath}\\Windows Defender Exploit Guard\\ASR"; var asrEnabled = RegistryUtil.GetDwordValue(RegistryHive.LocalMachine, asrKeyPath, "ExploitGuard_ASR_Rules"); AsrSettings = new AsrSettings( asrEnabled != null && (asrEnabled != 0) ); foreach (var value in RegistryUtil.GetValues(RegistryHive.LocalMachine, $"{asrKeyPath}\\Rules")) { AsrSettings.Rules.Add(new AsrRule( new Guid(value.Key), int.Parse((string)value.Value) )); } foreach (var value in RegistryUtil.GetValues(RegistryHive.LocalMachine, $"{asrKeyPath}\\ASROnlyExclusions")) { AsrSettings.Exclusions.Add(value.Key); } }
public MainForm(string[] args, GameManager gameManager) { this.gameManager = gameManager; MainForm.Instance = this; InitializeComponent(); this.SetupBaseForm(this.panel_formContent); overlay = new GameRunningOverlay(); overlay.OnStop += Overlay_OnStop; this.titleBarControl.Text = string.Format("Nucleus Coop v{0}", Globals.Version); controls = new Dictionary <string, GameControl>(); // selects the list of games, so the buttons look equal list_games.Select(); list_games.AutoScroll = false; if (args != null) { for (int i = 0; i < args.Length; i++) { string argument = args[i]; if (string.IsNullOrEmpty(argument)) { continue; } string extension = Path.GetExtension(argument); if (extension.ToLower().EndsWith("nc")) { // try installing the package in the arguments if user allows it if (MessageBox.Show("Would you like to install " + argument + "?", "Question", MessageBoxButtons.YesNo) == DialogResult.Yes) { gameManager.RepoManager.InstallPackage(argument); } } } } if (!gameManager.User.Options.RequestedToAssociateFormat) { gameManager.User.Options.RequestedToAssociateFormat = true; //if (MessageBox.Show("Would you like to associate Nucleus Package Files (*.nc) and nuke:// links to the application?", "Question", MessageBoxButtons.YesNo) == DialogResult.Yes) { string startLocation = Process.GetCurrentProcess().MainModule.FileName; if (!RegistryUtil.SetAssociation(".nc", "NucleusCoop", "Nucleus Package Files", startLocation)) { //MessageBox.Show("Failed to set association"); //gameManager.User.Options.RequestedToAssociateFormat = false; } RegistryUtil.RegisterUriScheme(); gameManager.User.Save(); } }
internal AccountWrapper(NSOutlook.Application item, string regPath, IStore store) : base(item) { this._accountId = System.IO.Path.GetFileName(regPath); this._regPath = regPath; this._store = store; // Cache the SmtpAddress, it is used as the key SmtpAddress = RegistryUtil.GetValueString(_regPath, OutlookConstants.REG_VAL_EMAIL, null); }
private void cmOK_Click(object sender, EventArgs e) { RegistryKey preferencesKey = RegistryUtil.GetUserKey("Preferences"); preferencesKey.SetValue("LogViewer", txtLogViewer.Text); this.DialogResult = DialogResult.OK; this.Close(); }
private static bool InternalGetUsePowerShell() { if (IsUsePowerShellSupported) { return((int)RegistryUtil.GetValue(RegistryPath, UsePowerShellKey) == 0); } return(false); }
public string[]? GetSubkeyNames(RegistryHive hive, string path) { if (!string.IsNullOrEmpty(ComputerName)) { return(RegistryUtil.GetSubkeyNames(hive, path, wmiRegProv)); } return(RegistryUtil.GetSubkeyNames(hive, path)); }
public static string GetOptions(string prefix) { if (ReturnDefaults) { return(null); } return(RegistryUtil.GetConfigValue <string>(prefix, null, null)); }
public byte[]? GetBinaryValue(RegistryHive hive, string path, string value) { if (!string.IsNullOrEmpty(ComputerName)) { return(RegistryUtil.GetBinaryValue(hive, path, value, wmiRegProv)); } return(RegistryUtil.GetBinaryValue(hive, path, value)); }
public uint?GetDwordValue(RegistryHive hive, string path, string value) { if (!string.IsNullOrEmpty(ComputerName)) { return(RegistryUtil.GetDwordValue(hive, path, value, wmiRegProv)); } return(RegistryUtil.GetDwordValue(hive, path, value)); }
public Dictionary <string, object> GetValues(RegistryHive hive, string path) { if (!string.IsNullOrEmpty(ComputerName)) { return(RegistryUtil.GetValues(hive, path, wmiRegProv)); } return(RegistryUtil.GetValues(hive, path)); }
public string[] GetUserSIDs() { if (!string.IsNullOrEmpty(ComputerName)) { return(RegistryUtil.GetUserSIDs(wmiRegProv)); } return(RegistryUtil.GetUserSIDs()); }
private static bool InternalGetAutoHideInTabletMode() { if (IsAutoHideInTabletModeSupported) { return((int)RegistryUtil.GetValue(RegistryPath, AutoHideInTabletModeKey) == 1); } return(false); }
public void SetLevel(LogLevel level) { if (level != _minLevel) { _minLevel = level; RegistryUtil.SetConfigValue(null, Constants.PLUGIN_REGISTRY_LOGLEVEL, (int)level, RegistryValueKind.DWord); OnLogLevelChanged(); } }
private static void InternalSetUsePowerShell(bool usePowerShell) { if (IsUsePowerShellSupported) { RegistryUtil.SetValue(RegistryPath, UsePowerShellKey, usePowerShell ? 0 : 1); } //UpdateTaskbar(); //todo: this update method does not seem to work on this }
public void Initialize() { try { _minLevel = (LogLevel)RegistryUtil.GetConfigValue <int>(null, Constants.PLUGIN_REGISTRY_LOGLEVEL, (int)_minLevel); OnLogLevelChanged(); } catch (Exception) { } DoLog(_minLevel, this, "Level initialized", null); }
internal static void GetConfigurationFromRegistry(string computerName, out CultureInfo[] locale, out Exception caughtException) { if (string.IsNullOrEmpty(computerName)) { throw new ArgumentNullException("computerName"); } caughtException = null; List <CultureInfo> list = new List <CultureInfo>(); try { using (RegistryKey registryKey = RegistryUtil.OpenRemoteBaseKey(RegistryHive.LocalMachine, computerName)) { using (RegistryKey registryKey2 = registryKey.OpenSubKey("SOFTWARE\\Microsoft\\ExchangeServer\\v15\\Language")) { if (registryKey2 != null) { string[] valueNames = registryKey2.GetValueNames(); if (valueNames != null) { foreach (string text in valueNames) { int culture = (int)registryKey2.GetValue(text, 0); try { CultureInfo cultureInfo = new CultureInfo(culture); if (cultureInfo.ThreeLetterWindowsLanguageName.Equals(text, StringComparison.InvariantCultureIgnoreCase)) { list.Add(cultureInfo); } } catch (ArgumentException) { TaskLogger.Trace("There is An inlvad data in the rigistry: SOFTWARE\\Microsoft\\ExchangeServer\\v15\\Language", new object[0]); } } } } } } } catch (SecurityException ex) { caughtException = ex; } catch (IOException ex2) { caughtException = ex2; } catch (UnauthorizedAccessException ex3) { caughtException = ex3; } locale = list.ToArray(); }
public override void Commit(IDictionary savedState) { base.Commit(savedState); Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); System.Diagnostics.Process.Start(Assembly.GetExecutingAssembly().Location); var filterServiceAssemblyPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "FilterServiceProvider.exe"); var uninstallStartInfo = new ProcessStartInfo(filterServiceAssemblyPath); uninstallStartInfo.Arguments = "Uninstall"; uninstallStartInfo.UseShellExecute = false; uninstallStartInfo.CreateNoWindow = true; var uninstallProc = Process.Start(uninstallStartInfo); uninstallProc.WaitForExit(); var installStartInfo = new ProcessStartInfo(filterServiceAssemblyPath); installStartInfo.Arguments = "Install"; installStartInfo.UseShellExecute = false; installStartInfo.CreateNoWindow = true; var installProc = Process.Start(installStartInfo); installProc.WaitForExit(); string restartFlagPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "CloudVeil", "restart.flag"); // 'norestart' not defined in Context.Parameters, so we can't use Context.IsParameterTrue. // This file gets defined by the filter service before shutting down. if (File.Exists(restartFlagPath)) { File.Delete(restartFlagPath); InitiateShutdown(null, null, 0, (uint)(ShutdownFlags.SHUTDOWN_FORCE_OTHERS | ShutdownFlags.SHUTDOWN_RESTART | ShutdownFlags.SHUTDOWN_RESTARTAPPS), 0); } RegistryUtil registry = new RegistryUtil(); if (savedState.Contains("__my_registry_auth_token")) { registry.AuthToken = savedState["__my_registry_auth_token"] as string; } if (savedState.Contains("__my_registry_user_email")) { registry.UserEmail = savedState["__my_registry_user_email"] as string; } EnsureStartServicePostInstall(filterServiceAssemblyPath); Environment.Exit(0); base.Dispose(); }
private static Dictionary <string, Token> GetEffectiveTokens(string prefix) { Dictionary <string, Token> tokens = new Dictionary <string, Token>(); foreach (bool localMachine in new bool[] { true, false }) { string value = RegistryUtil.GetConfigValue <string>(localMachine, prefix, null); if (!string.IsNullOrEmpty(value)) { foreach (string token in value.Split(',')) { if (!string.IsNullOrEmpty(token)) { string[] keyVal = token.Split(new[] { '=' }, 2); if (!string.IsNullOrEmpty(keyVal[0])) { string key = keyVal[0].ToLower(); if (key.StartsWith("-") || key.StartsWith("+")) { key = key.Substring(1); } Token existing; if (tokens.TryGetValue(key, out existing)) { existing.Value = token; } else { existing = new Token() { Key = key, Value = token }; existing.Order = tokens.Count; tokens.Add(key, existing); } if (localMachine) { existing.HasLocalMachine = true; existing.LocalMachineToken = token; } else { existing.HasCurrentUser = true; } } } } } } return(tokens); }
/// <summary> /// Loads the user's settings into the control. /// </summary> public override void Load() { string strBOSSPath = String.Empty; string strBOSSReg = String.Empty; string strWryePath = String.Empty; if (IntPtr.Size == 8) { strBOSSReg = @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\BOSS\"; } else { strBOSSReg = @"HKEY_LOCAL_MACHINE\SOFTWARE\BOSS\"; } if (EnvironmentInfo.Settings.SupportedTools[GameModeDescriptor.ModeId].ContainsKey("BOSS")) { strBOSSPath = EnvironmentInfo.Settings.SupportedTools[GameModeDescriptor.ModeId]["BOSS"]; } if (String.IsNullOrEmpty(strBOSSPath)) { if (RegistryUtil.CanReadKey(strBOSSReg)) { string strRegPath = (string)Registry.GetValue(strBOSSReg, "Installed Path", null); if (!String.IsNullOrWhiteSpace(strRegPath) && ((strRegPath.IndexOfAny(Path.GetInvalidPathChars()) >= 0) || !Directory.Exists(strRegPath))) { strBOSSPath = String.Empty; EnvironmentInfo.Settings.SupportedTools[GameModeDescriptor.ModeId]["BOSS"] = strBOSSPath; EnvironmentInfo.Settings.Save(); } else { strBOSSPath = strRegPath; } } } if (!String.IsNullOrEmpty(strBOSSPath) && Directory.Exists(strBOSSPath)) { BOSSDirectory = strBOSSPath; } if (EnvironmentInfo.Settings.SupportedTools[GameModeDescriptor.ModeId].ContainsKey("WryeBash")) { strWryePath = EnvironmentInfo.Settings.SupportedTools[GameModeDescriptor.ModeId]["WryeBash"]; if (!String.IsNullOrEmpty(strWryePath) && Directory.Exists(strWryePath)) { WryeBashDirectory = strWryePath; } } ValidateSettings(); }
private void chkStartOnBoot_CheckedChanged(object sender, EventArgs e) { try { RegistryUtil.SetStartup(chkStartOnBoot.Checked); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Handle(NetworkAdapterDomain domain) { foreach (var adapter in domain.GetNetworkAdapters()) { adapter.Characteristics = RegistryUtil.GetValueListByCondition(@"SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\" + adapter.Index.ToString("D4"), "Characteristics"); //转换成16进制 //int value; //Int32.TryParse(adapter.Characteristics, out value); //adapter.Characteristics = value.ToString("x"); } }
private string?GetServiceCommandFromRegistry(string serviceName) { try { return(RegistryUtil.GetStringValue(RegistryHive.LocalMachine, $"SYSTEM\\CurrentControlSet\\Services\\{serviceName}", "ImagePath")); } catch { return(null); } }
public UserInfo(RegistryKey key, string name) { this.name = name; admin = RegistryUtil.GetStringValue(key, "admin") == "1"; password_encoded = RegistryUtil.GetStringValue(key, "password"); selgroups = RegistryUtil.GetStringValue(key, "selgroups"); noalerts = RegistryUtil.GetStringValue(key, "noalerts") == "1"; lanonly = RegistryUtil.GetStringValue(key, "lanonly") == "1"; enabled = RegistryUtil.GetStringValue(key, "enabled") == "1"; usegroups = RegistryUtil.GetStringValue(key, "usegroups") == "1"; }
public void Save() { try { if (String.IsNullOrEmpty(Name)) { throw new Exception("Name is empty."); } if (existing != null) { rule = existing.Original; if (AppState.Instance.FindExisting(rule.ID, Name) != null) { throw new Exception("Name already exists."); } rule.Name = Name; AppState.Instance.UpdateRule(rule); } else { if (AppState.Instance.FindExisting(Name) != null) { throw new Exception("Name already exists."); } else if (SelectedChecker == null) { throw new Exception("No Checker selected."); } else if (SelectedChecker.HasExtensions && string.IsNullOrEmpty(SelectedExt)) { throw new Exception("No Extension selected."); } else if (SelectedChecker.HasPath && !RegistryUtil.IsValid(Path)) { throw new Exception("Path is invalid."); } rule = SelectedChecker.GetValues(Path, SelectedExt); rule.Name = Name; AppState.Instance.AddNewRule(rule); } Result = WindowResult.Saved; window.Close(); } catch (Exception e) { MessageBoxFactory.ShowError(e); } }
public MainWindow Run() { try { // US culture for price formatting var usCulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentCulture = usCulture; Thread.CurrentThread.CurrentUICulture = usCulture; Logger.Current.Info("Running bootstrapper..."); ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(30000)); Application.Current.DispatcherUnhandledException += OnDispatcherException; AppDomain.CurrentDomain.UnhandledException += OnException; ServiceLocator.Current .SetSingleton <ILogger>(Logger.Current) .SetSingleton <SettingsService>() .SetSingleton <CoinMarketService>() .SetSingleton <Navigator>(); settingsService = ServiceLocator.Current.Get <SettingsService>(); // Update the current app path if we are set as startup app Logger.Current.Info("Checking autostart status..."); ExceptionUtil.IgnoreException(() => { if (settingsService.CurrentSettings.AutoStart) { RegistryUtil.SetStartupApp(true); } }); var mainWindow = ServiceLocator.Current.Get <MainWindow>(); mainWindow.Top = settingsService.CurrentSettings.Top; mainWindow.Left = settingsService.CurrentSettings.Left; mainWindow.LocationChanged += OnWindowLocationChanged; mainWindow.SourceInitialized += OnWindowSourceInitialized; mainWindow.Closing += OnWindowClosing; mainWindow.StateChanged += OnWindowStateChanged; Logger.Current.Info("Bootstrapper done."); return(mainWindow); } catch (Exception ex) { ExceptionUtil.LogAndShowError("There was an error initializing the app, it will be shut down.", ex); Application.Current.Shutdown(); } return(null); }
/// <summary> /// Gets the LOOT launch command. /// </summary> /// <returns>The LOOT launch command.</returns> private string GetLOOTLaunchCommand() { var strLOOT = string.Empty; var strRegLOOT = string.Empty; if (IntPtr.Size == 8) { strRegLOOT = @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LOOT\"; } else { strRegLOOT = @"HKEY_LOCAL_MACHINE\SOFTWARE\LOOT\"; } if (EnvironmentInfo.Settings.SupportedTools.ContainsKey(GameMode.ModeId) && EnvironmentInfo.Settings.SupportedTools[GameMode.ModeId].ContainsKey("LOOT")) { strLOOT = EnvironmentInfo.Settings.SupportedTools[GameMode.ModeId]["LOOT"]; if (!string.IsNullOrWhiteSpace(strLOOT) && ((strLOOT.IndexOfAny(Path.GetInvalidPathChars()) >= 0) || !Directory.Exists(strLOOT))) { strLOOT = string.Empty; EnvironmentInfo.Settings.SupportedTools[GameMode.ModeId]["LOOT"] = string.Empty; EnvironmentInfo.Settings.Save(); } } if (string.IsNullOrEmpty(strLOOT)) { if (RegistryUtil.CanReadKey(strRegLOOT)) { var strRegPath = (string)Registry.GetValue(strRegLOOT, "Installed Path", null); if (!string.IsNullOrWhiteSpace(strRegPath) && ((strRegPath.IndexOfAny(Path.GetInvalidPathChars()) >= 0) || !Directory.Exists(strRegPath))) { strLOOT = string.Empty; EnvironmentInfo.Settings.SupportedTools[GameMode.ModeId]["LOOT"] = strLOOT; EnvironmentInfo.Settings.Save(); } else { strLOOT = strRegPath; } } } if (!string.IsNullOrWhiteSpace(strLOOT)) { strLOOT = Path.Combine(strLOOT, "LOOT.exe"); } return(strLOOT); }
/// <summary> /// Set things in motion so your service can do its work. /// </summary> protected override void OnStart(string[] args) { if (m_alreadyStarted == true) { return; } m_alreadyStarted = true; try { m_watchDirName = RegistryUtil.GetGlobalSightRegistryValue( "InDesignConvDir") + @"\indd"; DirectoryInfo watchDir = new DirectoryInfo(m_watchDirName); watchDir.Create(); Logger.Initialize(m_watchDirName + @"\InDesignConverter.log"); m_log = Logger.GetLogger(); m_log.Log("GlobalSight InDesign Converter starting up."); m_log.Log("Creating and starting threads to watch directory " + m_watchDirName); m_importConverterRunner = new ConverterRunner( new InDesignConverterImpl(InDesignConverterImpl.ConversionType.IMPORT), m_watchDirName); m_exportConverterRunner = new ConverterRunner( new InDesignConverterImpl(InDesignConverterImpl.ConversionType.EXPORT), m_watchDirName); m_importConverterRunner.Start(); m_exportConverterRunner.Start(); if (AllowInteractWithDesktop()) { m_InDesignApp = InDesignApplication.getInstance(); } else { throw new Exception("InDesign Converter Service needs to interact with desktop." + " The properties of InDesign Converter Service needs to " + "be changed to allow sevice to interact with desktop."); } } catch (Exception e) { string msg = "GlobalSight InDesign Converter failed to initialize because of: " + e.Message + "\r\n" + e.StackTrace; EventLog.WriteEntry(msg, EventLogEntryType.Error); Logger.LogWithoutException(msg); throw e; } }
private void SettingForm() { var link = RegistryUtil.GetConfigValueFromRegistry(RegistryType.ServerUrl); if (string.IsNullOrEmpty(link)) { DialogResult dr = MessageBox.Show("This application cannot be start. Would you like to config the application now?", "Config", MessageBoxButtons.OK); if (DialogResult.OK == dr) { (new Config()).ShowDialog(); } } }
public void LoadFromRegistry() { RegistryKey instancesKey = RegistryUtil.GetUserKey("Instances"); string[] subKeys = instancesKey.GetSubKeyNames(); foreach (string subKey in subKeys) { RegistryKey key = instancesKey.OpenSubKey(subKey, false); this.Add(new AemInstance(key)); } this.SortByName(); }