public static String getRegValue(String keyPath, String keyName) { Process process = ProcessHandler.getProcessAfterStart("reg", "query " + keyPath); String outStr = ProcessHandler.readOutputAndClose(process); String[] lines = outStr.Split("\n".ToCharArray()); for (int num = 0; num < lines.Length; num++) { String aLine = lines[num]; aLine = aLine.Replace("\r", ""); aLine = aLine.Trim(); String newLine = aLine.Replace(" ", " "); while (aLine.Equals(newLine) == false) { aLine = newLine; newLine = aLine.Replace(" ", " "); } String[] tokens = aLine.Split(" ".ToCharArray()); if (tokens[0].Equals(keyName)) { return(tokens[2]); } } return(null); }
public static Boolean delReg(String regPath, String regValueName, Boolean isForced) { String arg = (regValueName == null || regValueName.Length == 0) ? "" : " /v " + regValueName; arg += (isForced) ? " /f /va" : ""; _timer = new Timer(1000); _timer.AutoReset = false; _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed); Process process = ProcessHandler.getProcessBeforeStart("reg", "delete " + regPath + arg); _process = process; _timer.Start(); process.Start(); ProcessHandler.readOutputAndClose(process); _timer.Close(); return(_isOk); }
public static String getRegValue(String keyPath, String keyName) { Process process = ProcessHandler.getProcessAfterStart("reg", "query " + keyPath); String outStr = ProcessHandler.readOutputAndClose(process); String[] lines = outStr.Split("\n".ToCharArray()); for (int num = 0; num < lines.Length; num++) { String aLine = lines[num].Replace("\r", ""); if (aLine.Length == 0) { continue; } String key = FindNthString(aLine, 1); String value = FindNthStringToEnd(aLine, 3); if (key.Equals(keyName)) { return(value); } } return(null); }