/// <summary> /// Loads IFEO items /// </summary> /// <returns>The state of load</returns> public bool Load() { Log.WriteLine("Load registry"); IFEOKey = Registry.LocalMachine.OpenSubKey(Global.IFEORegPath, true); if (IFEOKey != null) { Items.Clear(); var items = from keyName in IFEOKey.GetSubKeyNames() let SubKey = IFEOKey.OpenSubKey(keyName, true) where SubKey != null where SubKey.GetValueNames().ToList().ConvertAll(d => d.ToLower()).IndexOf("debugger") > -1 select new IFEOItem { ManageByThis = ((string)GetValue(SubKey, "IFEOManage_Manage") == "True"), RegKey = SubKey, IFEOPath = (string)GetValue(SubKey, "IFEOManage_Path"), PEName = SubKey.Name.Split('\\').Last(), Debugger = SubKey.GetValue("Debugger").ToString(), Remark = (string)GetValue(SubKey, "IFEOManage_Remark"), RunMethod = (string)GetValue(SubKey, "IFEOManage_RunMethod") != "" ? (RunMethod)Enum.Parse(GetType(), (string)GetValue(SubKey, "IFEOManage_RunMethod")) : RunMethod.Close, }; foreach (var item in items) { _FormatDebuggerStringAndUpdate(item); Items.Add(item); } } else { Log.WriteLine("Cannot open registry"); Log.MessageBoxError((string)Application.Current.FindResource("cfmCannotOpenRegistry")); return(false); } return(true); }
public void SetupSubKeyPathAndAccessRights() { var pathArray = SubKey.Split('\\'); RegistryKey baseRegistryKey = BaseRegKeyCurrentUser; //string ssid = WindowsIdentityHelper.GetUniqueSecurityIdForCurrentUser(); WindowsIdentity windowsIdentity = WindowsIdentityHelper.GetWindowsIdentityForCurrentUser(); foreach (string path in pathArray) { RegistryKey sk1 = baseRegistryKey.OpenSubKey(path, RegistryKeyPermissionCheck.ReadWriteSubTree); bool userAccessGranted = true; if (sk1 == null) { sk1 = baseRegistryKey.CreateSubKey(path); } if (sk1 == null) { userAccessGranted = false; } if (userAccessGranted) { continue; } var registrySecurity = new RegistrySecurity(); IdentityReference identityReference = new NTAccount(windowsIdentity.Name); var rule = new RegistryAccessRule(identityReference, RegistryRights.CreateSubKey | RegistryRights.ReadKey | RegistryRights.WriteKey, AccessControlType.Allow); registrySecurity.AddAccessRule(rule); sk1 = baseRegistryKey.OpenSubKey(path, RegistryKeyPermissionCheck.ReadSubTree); sk1?.SetAccessControl(registrySecurity); } }
private static string RegRead(string KeyName) { return(UseReg((SubKey) => { return (string)SubKey.GetValue(KeyName); })); }
private static bool RegWrite(string KeyName, string Value) { return(UseReg((SubKey) => { SubKey.SetValue(KeyName, Value); return true; })); }
private static bool RegDelete(string KeyName) { return(UseReg((SubKey) => { SubKey.DeleteValue(KeyName); return true; })); }
public Subscription(SubKey key, Placement placement, Stream stream, IPlacementDispatcher disp, ExceptionSink exceptions, bool isImplicit) { Key = key; Placement = placement; Stream = stream; Dispatcher = disp; Exceptions = exceptions; IsImplicit = isImplicit; }
public SubKey Subscribe(Placement placement, bool isImplicit = false) { var subs = _dSubscriptions.Values.ToArray(); var foundImplicitSub = subs.FirstOrDefault(s => s.IsImplicit && s.Placement.Equals(placement)); if (foundImplicitSub != null) { return(foundImplicitSub.Key); } var subKey = new SubKey(Key, Guid.NewGuid()); var subscription = new Subscription(subKey, placement, this, _disp, _exceptions, isImplicit); _dSubscriptions[subKey.SubscriptionId] = subscription; return(subKey); }
void BackupCreateKeyTree(List <RegChange> rollbackRegistry) { char[] delim = { '/', '\\' }; string[] subKeys = SubKey.Split(delim, StringSplitOptions.RemoveEmptyEntries); string tempKey = ""; foreach (string t in subKeys) { tempKey += t + "\\"; if (!SubkeyExists(tempKey)) { //backup a "delete" key rollbackRegistry.Add(new RegChange(RegOperations.RemoveKey, RegBasekey, tempKey, Is32BitKey)); break; } } }
/// <summary> /// 修改注册表 /// </summary> /// <param name="key">注册表键</param> /// <param name="name">项</param> /// <param name="value">值</param> private void UpdatePortInRegedit(string key, string name, string value) { RegistryKey RootKey; RegistryKey SubKey; RootKey = Registry.LocalMachine; try { SubKey = RootKey.OpenSubKey(key, true); if (SubKey != null) { SubKey.SetValue(name, value); } SubKey.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\r" + ex.StackTrace); } }
public static List <FullKey> ReadTrainingKeys(string path) { List <FullKey> keys = new List <FullKey>(); try { using (StreamReader reader = new StreamReader(path)) { while (!reader.EndOfStream) { var line = reader.ReadLine(); var produceKey = line.Split(':'); var fragments = produceKey[1].Split('-'); var subKeysList = new List <SubKey>(); foreach (var fragment in fragments) { var subkey = new SubKey { Length = fragment.Length, Value = fragment }; subKeysList.Add(subkey); } var key = new FullKey { SubkeyLength = subKeysList.Count, SubKeys = subKeysList }; keys.Add(key); } return(keys); } } catch (IOException e) { Console.WriteLine("The file could not be read!"); Console.WriteLine(e.Message); throw; } }
public TestMapScene( Ecosystem ecosystem, Keycosystem keycosystem, DebugLogger debugLogger, Director director, DirectiveRenderer renderer, FpsCounter fpsCounter, MessageRouter messageRouter, GameTimer timer) { this.Ecosystem = ecosystem; this.Keycosystem = keycosystem; this.DebugLogger = debugLogger; this.Renderer = renderer; this.FpsCounter = fpsCounter; this.MessageRouter = messageRouter; this.Timer = timer; this.PlayerPosition = messageRouter.GetPubKey <Position2d>("player-position"); this.SubKey = messageRouter.GetSubKey(); this.Camera = renderer.GetViewport("default"); }
public void putInterval(SubKey keyname, int interval) { RegistryKey key; key = Registry.LocalMachine.CreateSubKey(keypath); key.SetValue(getSubKeyNameFor(keyname), DateTime.UtcNow.AddSeconds(interval).ToString("MM/dd/yyyy HH:mm:ss")); key.Close(); }
public void Unsubscribe(SubKey subKey) { Subscription _; _dSubscriptions.TryRemove(subKey.SubscriptionId, out _); }
public override int GetHashCode() { return(KeyMaskExtensions.ShiftAndWrap(Position.GetHashCode(), 2) ^ SubKey.GetHashCode()); }
static string getSubKeyNameFor(SubKey key) { return SubKeyNames[(int)key]; }
/// <summary> /// Adds subkey to registry key /// </summary> /// <returns>Registry key, or null if unable to be created</returns> public RegistryKey CreateSubKey() { RegistryKey regKey = null; if (string.Compare(RootKey, "HKEY_CLASSES_ROOT", StringComparison.Ordinal) == 0) { regKey = Registry.ClassesRoot; } else if (string.Compare(RootKey, "HKEY_CURRENT_USER", StringComparison.Ordinal) == 0) { regKey = Registry.CurrentUser; } else if (string.Compare(RootKey, "HKEY_LOCAL_MACHINE", StringComparison.Ordinal) == 0) { regKey = Registry.LocalMachine; } else if (string.Compare(RootKey, "HKEY_USERS", StringComparison.Ordinal) == 0) { regKey = Registry.Users; } else if (string.Compare(RootKey, "HKEY_CURRENT_CONFIG", StringComparison.Ordinal) == 0) { regKey = Registry.CurrentConfig; } if (string.IsNullOrEmpty(SubKey)) { return(regKey); } if (SubKey.IndexOf('\\') > 0) { foreach (var subKey in SubKey.Split('\\')) { try { regKey = regKey?.CreateSubKey(subKey); } catch (Exception ex) { Debug.WriteLine("Unable to create sub key ({0}) for registry path ({1}).\nError: {2}", subKey, RegistryKeyPath, ex.Message); regKey = null; } if (regKey == null) { break; } } } else { try { regKey = regKey?.CreateSubKey(SubKey); } catch (Exception ex) { Debug.WriteLine("Unable to create sub key ({0}) for registry path ({1}).\nError: {2}", SubKey, RegistryKeyPath, ex.Message); regKey = null; } } return(regKey); }
public void putValue(SubKey keyname, string value) { RegistryKey key; key = Registry.LocalMachine.CreateSubKey(keypath); key.SetValue(getSubKeyNameFor(keyname), value); key.Close(); }