/// <summary>Returns value from registry. If value doen't exists returns <see cref="defaultValue"/>.</summary> public static object GetValueData(string registryPath, object defaultValue) { var AdvReg = new AdvRegistry(registryPath); var Value = AdvReg.GetValueData(); return(Value ?? defaultValue); }
/// <summary> /// Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable, /// then returns the resulting string. /// Advanced feature: %LOCALAPPDATA% = Environment.SpecialFolder.LocalApplicationData /// Advanced feature: %HISTORY% = Environment.SpecialFolder.History /// Advanced feature: %INET_CACHE% = Environment.SpecialFolder.InternetCache /// Advanced feature: %SYSTEMP% = HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment|TEMP /// Advanced feature: %SYSTMP% = HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment|TMP /// </summary> public static String ExpandEnvironmentVariables(String path) { String result = path; result = Environment.ExpandEnvironmentVariables(result); result = Regex.Replace(result, "%LOCALAPPDATA%", Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), RegexOptions.Compiled | RegexOptions.IgnoreCase); result = Regex.Replace(result, "%HISTORY%", Environment.GetFolderPath(Environment.SpecialFolder.History), RegexOptions.Compiled | RegexOptions.IgnoreCase); result = Regex.Replace(result, "%INET_CACHE%", Environment.GetFolderPath(Environment.SpecialFolder.InternetCache), RegexOptions.Compiled | RegexOptions.IgnoreCase); result = Regex.Replace(result, "%RECENT%", Environment.GetFolderPath(Environment.SpecialFolder.Recent), RegexOptions.Compiled | RegexOptions.IgnoreCase); result = Regex.Replace(result, "%SYSTEMP%", (String)AdvRegistry.GetValueData("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\\\TEMP", "%SYSTEMP%"), RegexOptions.Compiled | RegexOptions.IgnoreCase); result = Regex.Replace(result, "%SYSTMP%", (String)AdvRegistry.GetValueData("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\\\TMP", "%SYSTMP%"), RegexOptions.Compiled | RegexOptions.IgnoreCase); return(result); }
/// <summary>Returns value from registry.</summary> public static object GetValueData(string registryPath) { var AdvReg = new AdvRegistry(registryPath); return(AdvReg.GetValueData()); }