Here are the examples of the csharp api Microsoft.Win32.RegistryKey.GetValue(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1103 Examples
19
View Source File : Exploit.cs
License : GNU General Public License v3.0
Project Creator : 0x00-0x00
License : GNU General Public License v3.0
Project Creator : 0x00-0x00
public static int GetCortana()
{
string KeyName = @"SOFTWARE\Policies\Microsoft\Windows\Windows Search";
string ValueName = "AllowCortana";
using (var key = Registry.LocalMachine.OpenSubKey(KeyName))
{
return (int)(key?.GetValue(ValueName) ?? -1);
}
}
19
View Source File : Program.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen
static void CleanSingle(string command)
{
string keypath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU";
string keyvalue = string.Empty;
string regcmd = string.Empty;
if (command.EndsWith("\\1"))
{
regcmd = command;
}
else
{
regcmd = string.Format("{0}\\1", command);
}
try
{
RegistryKey regkey;
regkey = Registry.CurrentUser.OpenSubKey(keypath, true);
if (regkey.ValueCount > 0)
{
foreach (string subKey in regkey.GetValueNames())
{
if(regkey.GetValue(subKey).ToString() == regcmd)
{
keyvalue = subKey;
regkey.DeleteValue(subKey);
Console.WriteLine(regcmd);
Console.WriteLine("[+] Cleaned {0} from HKCU:{1}", command, keypath);
}
}
if(keyvalue != string.Empty)
{
string mruchars = regkey.GetValue("MRUList").ToString();
int index = mruchars.IndexOf(keyvalue);
mruchars = mruchars.Remove(index, 1);
regkey.SetValue("MRUList", mruchars);
}
}
regkey.Close();
}
catch (ArgumentException)
{
Console.WriteLine("[-] Error: Selected Registry value does not exist");
}
}
19
View Source File : DarkFender.cs
License : MIT License
Project Creator : 0xyg3n
License : MIT License
Project Creator : 0xyg3n
public static void DisableFender(bool disableTamperProtection, bool disableDefender)
{
if (disableTamperProtection) // once we have TrustedInstaller Permission disable the tamper
{
RegistryKey Tamper = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows Defender\Features", true);
Tamper.SetValue("TamperProtection", 4 , RegistryValueKind.DWord); // 4 means disabled 5 means enabled
/*var timi = Tamper.GetValue("TamperProtection"); //this was for debug*/
Tamper.Close();
/*MessageBox.Show(timi.ToString());*/
if (disableDefender)
{
RegistryKey PolicyFromDisable = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Policies\Microsoft\Windows Defender", true);
try
{
PolicyFromDisable.GetValue("DisableAntiSpyware");
//create a new key
PolicyFromDisable.CreateSubKey("DisableAntiSpyware");
PolicyFromDisable.SetValue("DisableAntiSpyware", 1, RegistryValueKind.DWord); // 0 means enabled 1 means disabled
/*var timi3 = PolicyFromDisable.GetValue("DisableAntiSpyware");
MessageBox.Show(timi3.ToString());*/
//set the value
}
catch (Exception) // if the value does not exist create it
{
//create a new key
PolicyFromDisable.CreateSubKey("DisableAntiSpyware");
PolicyFromDisable.SetValue("DisableAntiSpyware", 1, RegistryValueKind.DWord); // 0 means enabled 1 means disabled
/*var timi3 = PolicyFromDisable.GetValue("DisableAntiSpyware");
MessageBox.Show(timi3.ToString());*/
//set the value
}
}
}
}
19
View Source File : Program.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen
static void QueryReg()
{
try
{
string keypath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU";
Console.WriteLine("Current HKCU:{0} values", keypath);
RegistryKey regkey;
regkey = Registry.CurrentUser.OpenSubKey(keypath, true);
if (regkey.ValueCount > 0)
{
foreach (string subKey in regkey.GetValueNames())
{
Console.WriteLine("[+] Key Name : {0}", subKey);
Console.WriteLine(" Value : {0}", regkey.GetValue(subKey).ToString());
Console.WriteLine();
}
}
regkey.Close();
}
catch (Exception ex)
{
Console.WriteLine("[-] Error: {0}", ex.Message);
}
}
19
View Source File : Form1.cs
License : MIT License
Project Creator : 200Tigersbloxed
License : MIT License
Project Creator : 200Tigersbloxed
private void button1_Click(object sender, EventArgs e)
{
// Find the Steam folder
RegistryKey rk1s = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64);
if (rk1s != null)
{
RegistryKey rk2 = rk1s.OpenSubKey("Software");
if (rk2 != null)
{
RegistryKey rk3 = rk2.OpenSubKey("Valve");
if (rk3 != null)
{
RegistryKey rk4 = rk3.OpenSubKey("Steam");
if (rk4 != null)
{
userownssteam = true;
string phrase = rk4.GetValue("SteamPath").ToString();
steaminstallpath = phrase;
}
}
}
}
if(userownssteam == false)
{
MessageBox.Show("Uh Oh!", "Steam Could not be found!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else{
bsl = steaminstallpath + @"/steamapps/common/Beat Saber";
if(Directory.Exists(bsl))
{
if(File.Exists(bsl + @"\Beat Saber.exe"))
{
if(File.Exists(bsl + @"\IPA.exe"))
{
textBox1.Text = bsl;
pictureBox1.Image = BSMulti_Installer2.Properties.Resources.tick;
button4.BackColor = SystemColors.MenuHighlight;
allownext = true;
runVerifyCheck();
findMultiplayerVersion();
}
else
{
MessageBox.Show("IPA.exe Could not be found! Is Beat Saber Modded?", "Uh Oh!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Beat Saber.exe Could not be found! Is Beat Saber Installed?", "Uh Oh!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Beat Saber Could not be found! Is Beat Saber Installed under Steam?", "Uh Oh!", MessageBoxButtons.OK, MessageBoxIcon.Error);
bsl = "";
}
}
}
19
View Source File : Form1.cs
License : MIT License
Project Creator : 200Tigersbloxed
License : MIT License
Project Creator : 200Tigersbloxed
private void button2_Click(object sender, EventArgs e)
{
//Find the Oculus Folder
RegistryKey rk1s = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
if (rk1s != null)
{
RegistryKey rk2 = rk1s.OpenSubKey("Software");
if (rk2 != null)
{
RegistryKey rk3 = rk2.OpenSubKey("WOW6432Node");
if (rk3 != null)
{
RegistryKey rk4 = rk3.OpenSubKey("Oculus VR, LLC");
if (rk4 != null)
{
RegistryKey rk5 = rk4.OpenSubKey("Oculus");
if(rk5 != null)
{
RegistryKey rk6 = rk5.OpenSubKey("Config");
if(rk6 != null)
{
userownsoculus = true;
string phrase = rk6.GetValue("InitialAppLibrary").ToString();
oculusinstallpath = phrase;
}
}
}
}
}
}
if (userownsoculus == false)
{
MessageBox.Show("Oculus Could not be found!", "Uh Oh!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
bsl = oculusinstallpath + @"/Software/Software/hyperbolic-magnetism-beat-saber";
if (Directory.Exists(bsl))
{
if (File.Exists(bsl + @"\Beat Saber.exe"))
{
if (File.Exists(bsl + @"\IPA.exe"))
{
textBox1.Text = bsl;
pictureBox1.Image = BSMulti_Installer2.Properties.Resources.tick;
button4.BackColor = SystemColors.MenuHighlight;
allownext = true;
runVerifyCheck();
findMultiplayerVersion();
}
else
{
MessageBox.Show("IPA.exe Could not be found! Is Beat Saber Modded?", "Uh Oh!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Beat Saber.exe Could not be found! Is Beat Saber Installed?", "Uh Oh!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Beat Saber Could not be found! Is Beat Saber Installed under Oculus?", "Uh Oh!", MessageBoxButtons.OK, MessageBoxIcon.Error);
bsl = "";
}
}
}
19
View Source File : ProxySetting.cs
License : GNU General Public License v3.0
Project Creator : 2dust
License : GNU General Public License v3.0
Project Creator : 2dust
public static bool UsedProxy()
{
RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true);
if (rk.GetValue("ProxyEnable").ToString() == "1")
{
rk.Close();
return true;
}
else
{
rk.Close();
return false;
}
}
19
View Source File : ProxySetting.cs
License : GNU General Public License v3.0
Project Creator : 2dust
License : GNU General Public License v3.0
Project Creator : 2dust
public static string GetProxyProxyServer()
{
RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true);
string ProxyServer = rk.GetValue("ProxyServer").ToString();
rk.Close();
return ProxyServer;
}
19
View Source File : Utils.cs
License : GNU General Public License v3.0
Project Creator : 2dust
License : GNU General Public License v3.0
Project Creator : 2dust
public static string RegReadValue(string path, string name, string def)
{
RegistryKey regKey = null;
try
{
regKey = Registry.CurrentUser.OpenSubKey(path, false);
string value = regKey?.GetValue(name) as string;
if (IsNullOrEmpty(value))
{
return def;
}
else
{
return value;
}
}
catch (Exception ex)
{
SaveLog(ex.Message, ex);
}
finally
{
regKey?.Close();
}
return def;
}
19
View Source File : dlgSettings.cs
License : MIT License
Project Creator : 86Box
License : MIT License
Project Creator : 86Box
private void LoadSettings()
{
try
{
RegistryKey regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box", false); //Open the key as read only
//If the key doesn't exist yet, fallback to defaults
if (regkey == null)
{
MessageBox.Show("86Box Manager settings could not be loaded. This is normal if you're running 86Box Manager for the first time. Default values will be used.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
//Create the key and reopen it for write access
Registry.CurrentUser.CreateSubKey(@"SOFTWARE\86Box");
regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box", true);
regkey.CreateSubKey("Virtual Machines");
txtCFGdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\86Box VMs\";
txtEXEdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\86Box\";
cbxMinimize.Checked = false;
cbxShowConsole.Checked = true;
cbxMinimizeTray.Checked = false;
cbxCloseTray.Checked = false;
cbxLogging.Checked = false;
txtLaunchTimeout.Text = "5000";
txtLogPath.Text = "";
cbxGrid.Checked = false;
btnBrowse3.Enabled = false;
txtLogPath.Enabled = false;
SaveSettings(); //This will write the default values to the registry
}
else
{
txtEXEdir.Text = regkey.GetValue("EXEdir").ToString();
txtCFGdir.Text = regkey.GetValue("CFGdir").ToString();
txtLaunchTimeout.Text = regkey.GetValue("LaunchTimeout").ToString();
txtLogPath.Text = regkey.GetValue("LogPath").ToString();
cbxMinimize.Checked = Convert.ToBoolean(regkey.GetValue("MinimizeOnVMStart"));
cbxShowConsole.Checked = Convert.ToBoolean(regkey.GetValue("ShowConsole"));
cbxMinimizeTray.Checked = Convert.ToBoolean(regkey.GetValue("MinimizeToTray"));
cbxCloseTray.Checked = Convert.ToBoolean(regkey.GetValue("CloseToTray"));
cbxLogging.Checked = Convert.ToBoolean(regkey.GetValue("EnableLogging"));
cbxGrid.Checked = Convert.ToBoolean(regkey.GetValue("EnableGridLines"));
txtLogPath.Enabled = cbxLogging.Checked;
btnBrowse3.Enabled = cbxLogging.Checked;
}
regkey.Close();
}
catch (Exception ex)
{
txtCFGdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents) + @"\86Box VMs";
txtEXEdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\86Box";
cbxMinimize.Checked = false;
cbxShowConsole.Checked = true;
cbxMinimizeTray.Checked = false;
cbxCloseTray.Checked = false;
cbxLogging.Checked = false;
txtLaunchTimeout.Text = "5000";
txtLogPath.Text = "";
cbxGrid.Checked = false;
txtLogPath.Enabled = false;
btnBrowse3.Enabled = false;
}
}
19
View Source File : dlgSettings.cs
License : MIT License
Project Creator : 86Box
License : MIT License
Project Creator : 86Box
private bool CheckForChanges()
{
RegistryKey regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box");
try
{
btnApply.Enabled = (
txtEXEdir.Text != regkey.GetValue("EXEdir").ToString() ||
txtCFGdir.Text != regkey.GetValue("CFGdir").ToString() ||
txtLogPath.Text != regkey.GetValue("LogPath").ToString() ||
txtLaunchTimeout.Text != regkey.GetValue("LaunchTimeout").ToString() ||
cbxMinimize.Checked != Convert.ToBoolean(regkey.GetValue("MinimizeOnVMStart")) ||
cbxShowConsole.Checked != Convert.ToBoolean(regkey.GetValue("ShowConsole")) ||
cbxMinimizeTray.Checked != Convert.ToBoolean(regkey.GetValue("MinimizeToTray")) ||
cbxCloseTray.Checked != Convert.ToBoolean(regkey.GetValue("CloseToTray")) ||
cbxLogging.Checked != Convert.ToBoolean(regkey.GetValue("EnableLogging")) ||
cbxGrid.Checked != Convert.ToBoolean(regkey.GetValue("EnableGridLines")));
return btnApply.Enabled;
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
return true; //For now let's just return true if anything goes wrong
}
finally
{
regkey.Close();
}
}
19
View Source File : ExportExampleHelper.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public static string GetreplacedemblyPathFromRegistry()
{
using (var registryKey = Registry.CurrentUser.OpenSubKey(RegistryKeyString))
{
if (registryKey != null)
{
var replacedemblyPathFromRegistry = string.Format("{0}{1}", registryKey.GetValue("Path"), @"Lib\net40\");
return replacedemblyPathFromRegistry;
}
}
return null;
}
19
View Source File : ChromiumBrowser.cs
License : MIT License
Project Creator : acandylevey
License : MIT License
Project Creator : acandylevey
public bool IsRegistered(string Hostname, string ManifestPath)
{
string targetKeyPath = regHostnameKeyLocation + Hostname;
RegistryKey regKey = Registry.CurrentUser.OpenSubKey(targetKeyPath, true);
if (regKey != null && regKey.GetValue("").ToString() == ManifestPath)
return true;
return false;
}
19
View Source File : SystemInfo.cs
License : MIT License
Project Creator : Accelerider
License : MIT License
Project Creator : Accelerider
private static DotNetFramework Get45PlusFromRegistry()
{
const string subKey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";
using (RegistryKey ndpKey = RegistryKey
.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)
.OpenSubKey(subKey))
{
return ndpKey?.GetValue("Release") != null
? CheckFor45PlusVersion((int)ndpKey.GetValue("Release"))
: DotNetFramework.Unknown;
}
}
19
View Source File : RegistryHandler.cs
License : MIT License
Project Creator : adrianmteo
License : MIT License
Project Creator : adrianmteo
public static WindowsTheme GetAppTheme()
{
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(KeyPath))
{
object registryValueObject = key?.GetValue("AppsUseLightTheme");
if (registryValueObject == null)
{
return WindowsTheme.Light;
}
int registryValue = (int)registryValueObject;
return registryValue > 0 ? WindowsTheme.Light : WindowsTheme.Dark;
}
}
19
View Source File : SystemInformation.cs
License : MIT License
Project Creator : afxw
License : MIT License
Project Creator : afxw
private static string GetProductName()
{
var key = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion";
return Registry.LocalMachine.OpenSubKey(key).GetValue("ProductName").ToString();
}
19
View Source File : RegistryHelper.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu
License : Mozilla Public License 2.0
Project Creator : agebullhu
public static string GetStringValue(RegistryKey key, string name, string def)
{
var re = key.GetValue(name);
if (re == null)
{
key.SetValue(name, def);
key.Flush();
return def;
}
return re.ToString();
}
19
View Source File : RegistryHelper.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu
License : Mozilla Public License 2.0
Project Creator : agebullhu
public static bool GetBoolValue(RegistryKey key, string name, bool def)
{
var re = key.GetValue(name);
if (re == null)
{
key.SetValue(name, def);
key.Flush();
return def;
}
return Convert.ToBoolean(re);
}
19
View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : AgentRev
License : GNU General Public License v3.0
Project Creator : AgentRev
void IsGameInstalled()
{
string lePath = Path.Combine(ProgramFilesx86(), @"Steam\" + gameMode.GetValue("c_exeDirectory") + @"\" + gameMode.GetValue("c_exe") + ".exe");
TryPath(lePath);
if (!gameFound)
{
RegistryKey steamSubKey = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam\Apps\" + gameMode.GetValue("c_gameID"));
if (steamSubKey != null)
{
object installed = steamSubKey.GetValue("Installed");
if (installed != null && Convert.ToInt32(installed) > 0)
{
gameFound = true;
}
}
}
}
19
View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : AgentRev
License : GNU General Public License v3.0
Project Creator : AgentRev
void IsGameInstalled()
{
string lePath = Path.Combine(ProgramFilesx86(), @"Steam\" + gameMode.GetValue("c_exeDirectory") + @"\" + gameMode.GetValue("c_exe") + ".exe");
TryPath(lePath);
if (!gameFound)
{
RegistryKey steamSubKey = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam");
if (steamSubKey != null)
{
object steamPath = steamSubKey.GetValue("SteamPath");
if (steamPath != null && !String.IsNullOrEmpty(steamPath.ToString()))
{
lePath = Path.Combine(steamPath.ToString(), gameMode.GetValue("c_exeDirectory") + @"\" + gameMode.GetValue("c_exe") + ".exe");
TryPath(lePath);
}
}
}
}
19
View Source File : KeyUtil.cs
License : GNU General Public License v3.0
Project Creator : ahmed605
License : GNU General Public License v3.0
Project Creator : ahmed605
public string FindGameDirectory()
{
if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), ExecutableName)))
{
dir = Directory.GetCurrentDirectory();
}
else
{
if (ExecutableName == "GTAIV.exe" && File.Exists(@"path.iv") && !StringExtensions.IsNullOrWhiteSpace(File.ReadAllText(@"path.iv")) && File.Exists(Path.Combine(File.ReadAllText(@"path.iv"), ExecutableName)))
{
dir = File.ReadAllText(@"path.iv");
}
else
{
if (ExecutableName == "EFLC.exe" && File.Exists(@"path.eflc") && !StringExtensions.IsNullOrWhiteSpace(File.ReadAllText(@"path.eflc")) && File.Exists(Path.Combine(File.ReadAllText(@"path.eflc"), ExecutableName)))
{
dir = File.ReadAllText(@"path.eflc");
}
else
{
var keys = PathRegistryKeys;
foreach (var s in keys)
{
RegistryKey key;
if ((key = Registry.LocalMachine.OpenSubKey(s)) != null)
{
if (key.GetValue("InstallFolder") != null && File.Exists(Path.Combine(key.GetValue("InstallFolder").ToString(), ExecutableName)))
{
dir = key.GetValue("InstallFolder").ToString();
key.Close();
break;
}
else
{
var fbd = new VistaFolderBrowserDialog();
fbd.Description = "Select game folder";
//DialogResult result = fbd.ShowDialog();
if (fbd.ShowDialog() == DialogResult.OK && !StringExtensions.IsNullOrWhiteSpace(fbd.SelectedPath))
{
dir = fbd.SelectedPath;
break;
}
else
{
MessageBox.Show("Please select game folder.");
Application.Exit();
}
}
}
}
}
}
}
return dir;
}
19
View Source File : ExternalEditor.cs
License : GNU General Public License v3.0
Project Creator : ahmed605
License : GNU General Public License v3.0
Project Creator : ahmed605
public bool SupportsExtension(string extension)
{
try
{
var key = Registry.ClreplacedesRoot.OpenSubKey("." + extension);
if (key == null)
{
return false;
}
var defaultValue = key.GetValue("").ToString();
if (defaultValue == null)
{
return false;
}
var shellOpenKey = Registry.ClreplacedesRoot.OpenSubKey(defaultValue + @"\shell\open");
return shellOpenKey != null;
}
catch
{
return false;
}
}
19
View Source File : MainWindow.xaml.cs
License : GNU Affero General Public License v3.0
Project Creator : aianlinb
License : GNU Affero General Public License v3.0
Project Creator : aianlinb
private async void OnLoaded(object sender, RoutedEventArgs e) {
if (SteamMode)
replacedle += " (SteamMode)";
if (BundleMode)
replacedle += " (SteamMode)";
// Version Check
try {
var http = new HttpClient {
Timeout = TimeSpan.FromSeconds(2)
};
http.DefaultRequestHeaders.Add("User-Agent", "VisualGGPK2");
var json = await http.GetStringAsync("https://api.github.com/repos/aianlinb/LibGGPK2/releases");
var match = Regex.Match(json, "(?<=\"tag_name\":\"v).*?(?=\")");
var currentVersion = replacedembly.GetEntryreplacedembly().GetName().Version;
var versionText = $"{currentVersion.Major}.{currentVersion.Minor}.{currentVersion.Build}";
if (match.Success && match.Value != versionText && MessageBox.Show(this, $"Found a new update on GitHub!\n\nCurrent Version: {versionText}\nLatest Version: {match.Value}\n\nDownload now?", "VisualGGPK2", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) {
Process.Start(new ProcessStartInfo("https://github.com/aianlinb/LibGGPK2/releases") { UseShellExecute = true });
Close();
return;
}
http.Dispose();
} catch { }
// GGPK Selection
if (FilePath == null) {
var ofd = new OpenFileDialog {
DefaultExt = "ggpk",
FileName = SteamMode ? "_.index.bin" : "Content.ggpk",
Filter = SteamMode ? "Index Bundle File|*.index.bin" : "GGPK File|*.ggpk"
};
var setting = Properties.Settings.Default;
if (setting.GGPKPath == "") {
setting.Upgrade();
setting.Save();
}
if (setting.GGPKPath == "") {
string path;
path = Registry.CurrentUser.OpenSubKey(@"Software\GrindingGearGames\Path of Exile")?.GetValue("InstallLocation") as string;
if (path != null && File.Exists(path + @"\Content.ggpk")) // Get POE path
ofd.InitialDirectory = path.TrimEnd('\\');
} else
ofd.InitialDirectory = setting.GGPKPath;
if (ofd.ShowDialog() == true) {
setting.GGPKPath = Directory.GetParent(FilePath = ofd.FileName).FullName;
setting.Save();
} else {
Close();
return;
}
}
// Initial GGPK
await Task.Run(() => ggpkContainer = new GGPKContainer(FilePath, BundleMode, SteamMode));
// Initial ContextMenu
var mi = new MenuItem { Header = "Export" };
mi.Click += OnExportClicked;
TreeMenu.Items.Add(mi);
mi = new MenuItem { Header = "Replace" };
mi.Click += OnReplaceClicked;
TreeMenu.Items.Add(mi);
mi = new MenuItem { Header = "Recovery" };
mi.Click += OnRecoveryClicked;
TreeMenu.Items.Add(mi);
mi = new MenuItem { Header = "Convert dds to png" };
mi.Click += OnSavePngClicked;
TreeMenu.Items.Add(mi);
var imageMenu = new ContextMenu();
mi = new MenuItem { Header = "Save as png" };
mi.Click += OnSavePngClicked;
imageMenu.Items.Add(mi);
ImageView.ContextMenu = imageMenu;
var root = CreateNode(ggpkContainer.rootDirectory);
Tree.Items.Add(root); // Initial TreeView
root.IsExpanded = true;
FilterButton.IsEnabled = true;
if (!SteamMode)
AllowGameOpen.IsEnabled = true;
// Mark the free spaces in data section of dat files
DatReferenceDataTable.CellStyle = new Style(typeof(DataGridCell));
DatReferenceDataTable.CellStyle.Setters.Add(new EventSetter(LoadedEvent, new RoutedEventHandler(OnCellLoaded)));
// Make changes to DatContainer after editing DatTable
DatTable.CellEditEnding += OnDatTableCellEdit;
// Make changes to DatContainer after editing DatReferenceDataTable
DatReferenceDataTable.CellEditEnding += OnDatReferenceDataTableCellEdit;
TextView.AppendText("\r\n\r\nDone!\r\n");
}
19
View Source File : ScriptAssetOpener.cs
License : MIT License
Project Creator : akof1314
License : MIT License
Project Creator : akof1314
private static string LuaExecutablePath()
{
using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.lua\\UserChoice"))
{
if (registryKey != null)
{
string val = registryKey.GetValue("Progid") as string;
if (!string.IsNullOrEmpty(val))
{
val = "Software\\Clreplacedes\\" + val + "\\shell\\open\\command";
using (RegistryKey registryKey2 = Registry.CurrentUser.OpenSubKey(val))
{
string val3 = LuaExecutablePathInter(registryKey2);
if (!string.IsNullOrEmpty(val3))
{
return val3;
}
}
}
}
}
using (RegistryKey registryKey = Registry.ClreplacedesRoot.OpenSubKey(".lua"))
{
if (registryKey != null)
{
string val = registryKey.GetValue(null) as string;
if (val != null)
{
val += "\\shell\\open\\command";
using (RegistryKey registryKey2 = Registry.ClreplacedesRoot.OpenSubKey(val))
{
string val3 = LuaExecutablePathInter(registryKey2);
if (!string.IsNullOrEmpty(val3))
{
return val3;
}
}
}
}
}
return String.Empty;
}
19
View Source File : ScriptAssetOpener.cs
License : MIT License
Project Creator : akof1314
License : MIT License
Project Creator : akof1314
private static string LuaExecutablePathInter(RegistryKey registryKey2)
{
if (registryKey2 != null)
{
string val2 = registryKey2.GetValue(null) as string;
if (!string.IsNullOrEmpty(val2))
{
string val3 = val2;
int pos = val2.IndexOf(" \"", StringComparison.Ordinal);
if (pos != -1)
{
val3 = val2.Substring(0, pos);
}
val3 = val3.Trim('"');
return val3;
}
}
return String.Empty;
}
19
View Source File : ActionMods.cs
License : MIT License
Project Creator : AlbertMN
License : MIT License
Project Creator : AlbertMN
private static string GetPythonPath(string requiredVersion = "", string maxVersion = "") {
string[] possiblePythonLocations = new string[3] {
@"HKLM\SOFTWARE\Python\PythonCore\",
@"HKCU\SOFTWARE\Python\PythonCore\",
@"HKLM\SOFTWARE\Wow6432Node\Python\PythonCore\"
};
//Version number, install path
Dictionary<string, string> pythonLocations = new Dictionary<string, string>();
foreach (string possibleLocation in possiblePythonLocations) {
string regKey = possibleLocation.Substring(0, 4), actualPath = possibleLocation.Substring(5);
RegistryKey theKey = (regKey == "HKLM" ? Registry.LocalMachine : Registry.CurrentUser);
RegistryKey theValue = theKey.OpenSubKey(actualPath);
foreach (var v in theValue.GetSubKeyNames()) {
RegistryKey productKey = theValue.OpenSubKey(v);
if (productKey != null) {
try {
string pythonExePath = productKey.OpenSubKey("InstallPath").GetValue("ExecutablePath").ToString();
if (pythonExePath != null && pythonExePath != "") {
//Console.WriteLine("Got python version; " + v + " at path; " + pythonExePath);
pythonLocations.Add(v.ToString(), pythonExePath);
}
} catch {
//Install path doesn't exist
}
}
}
}
if (pythonLocations.Count > 0) {
System.Version desiredVersion = new System.Version(requiredVersion == "" ? "0.0.1" : requiredVersion),
maxPVersion = new System.Version(maxVersion == "" ? "999.999.999" : maxVersion);
string highestVersion = "", highestVersionPath = "";
foreach (KeyValuePair<string, string> pVersion in pythonLocations) {
//TODO; if on 64-bit machine, prefer the 64 bit version over 32 and vice versa
int index = pVersion.Key.IndexOf("-"); //For x-32 and x-64 in version numbers
string formattedVersion = index > 0 ? pVersion.Key.Substring(0, index) : pVersion.Key;
System.Version thisVersion = new System.Version(formattedVersion);
int comparison = desiredVersion.CompareTo(thisVersion),
maxComparison = maxPVersion.CompareTo(thisVersion);
if (comparison <= 0) {
//Version is greater or equal
if (maxComparison >= 0) {
desiredVersion = thisVersion;
highestVersion = pVersion.Key;
highestVersionPath = pVersion.Value;
} else {
//Console.WriteLine("Version is too high; " + maxComparison.ToString());
}
} else {
//Console.WriteLine("Version (" + pVersion.Key + ") is not within the spectrum.");
}
}
return highestVersionPath;
}
return "";
}
19
View Source File : CloudServiceFunctions.cs
License : MIT License
Project Creator : AlbertMN
License : MIT License
Project Creator : AlbertMN
public static string GetGoogleDriveFolder() {
//New Google Drive check first
string registryKey = @"Software\Google\DriveFS";
RegistryKey key = Registry.CurrentUser.OpenSubKey(registryKey);
if (key != null || Directory.Exists(Environment.ExpandEnvironmentVariables("%programfiles%") + @"\Google\Drive File Stream")) {
//New google Drive seems to be installed
DriveInfo[] allDrives = DriveInfo.GetDrives();
//Check if it's a virual drive
foreach (DriveInfo d in allDrives) {
if (d.VolumeLabel == "Google Drive") {
string check = Path.Combine(d.Name, "My Drive");
if (Directory.Exists(check)) {
return check;
}
}
}
//Not a virtual drive, check the user's folder
string userDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
if (Directory.Exists(userDir)) {
foreach (string dir in Directory.GetDirectories(userDir)) {
if (dir.Contains("My Drive")) {
//Pretty sure it's Google Drive... But bad practice maybe...?
return dir;
}
}
}
return "partial";
}
//No? Check the old one
registryKey = @"Software\Google\Drive";
key = Registry.CurrentUser.OpenSubKey(registryKey);
if (key != null) {
string installed = key.GetValue("Installed").ToString();
key.Close();
if (installed != null) {
if (installed == "True") {
string checkPath = Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "Google Drive");
if (Directory.Exists(checkPath)) {
return checkPath;
}
return "partial";
}
}
}
return "";
}
19
View Source File : MainProgram.cs
License : MIT License
Project Creator : AlbertMN
License : MIT License
Project Creator : AlbertMN
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs args) {
Exception e = (Exception)args.ExceptionObject;
string errorLogLoc = Path.Combine(dataFolderLocation, "error_log.txt");
string subKey = @"SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion";
RegistryKey thekey = Registry.LocalMachine;
RegistryKey skey = thekey.OpenSubKey(subKey);
string windowsVersionName = skey.GetValue("ProductName").ToString();
string rawWindowsVersion = Environment.OSVersion.ToString();
int totalExecutions = 0;
foreach (int action in Properties.Settings.Default.TotalActionsExecuted) {
totalExecutions += action;
}
if (File.Exists(errorLogLoc))
try {
File.Delete(errorLogLoc);
} catch {
DoDebug("Failed to delete error log");
}
if (!File.Exists(errorLogLoc)) {
try {
using (var tw = new StreamWriter(errorLogLoc, true)) {
tw.WriteLine("OS;");
tw.WriteLine("- " + windowsVersionName);
tw.WriteLine("- " + rawWindowsVersion);
tw.WriteLine();
tw.WriteLine("ACC info;");
tw.WriteLine("- Version; " + softwareVersion + ", " + releaseDate);
tw.WriteLine("- UID; " + Properties.Settings.Default.UID);
tw.WriteLine("- Running from; " + currentLocationFull);
tw.WriteLine("- Start with Windows; " + (ACCStartsWithWindows() ? "[Yes]" : "[No]"));
tw.WriteLine("- Check for updates; " + (Properties.Settings.Default.CheckForUpdates ? "[Yes]" : "[No]"));
tw.WriteLine("- In beta program; " + (Properties.Settings.Default.BetaProgram ? "[Yes]" : "[No]"));
tw.WriteLine("- Has completed setup guide; " + (Properties.Settings.Default.HasCompletedTutorial ? "[Yes]" : "[No]"));
tw.WriteLine("- Check path; " + CheckPath());
tw.WriteLine("- Check extension; " + Properties.Settings.Default.ActionFileExtension);
tw.WriteLine("- Actions executed; " + totalExecutions);
tw.WriteLine("- replacedistant type; " + "[Google replacedistant: " + Properties.Settings.Default.replacedistantType[0] + "] [Alexa: " + Properties.Settings.Default.replacedistantType[1] + "] [Unknown: " + Properties.Settings.Default.replacedistantType[1] + "]");
tw.WriteLine();
tw.WriteLine(e);
tw.Close();
}
} catch {
//Caught exception when trying to log exception... *sigh*
}
}
File.AppendAllText(errorLogLoc, DateTime.Now.ToString() + ": " + e + Environment.NewLine);
if (debug) {
Console.WriteLine(e);
}
MessageBox.Show("A critical error occurred. The developer has been notified and will resolve this issue ASAP! Try and start ACC again, and avoid whatever just made it crash (for now) :)", "ACC | Error");
}
19
View Source File : MainProgram.cs
License : MIT License
Project Creator : AlbertMN
License : MIT License
Project Creator : AlbertMN
public static bool ACCStartsWithWindows() {
if (!Properties.Settings.Default.StartsUsingRegistry) {
try {
using (TaskService ts = new TaskService()) {
return ts.GetTask(@"replacedistantComputerControl startup") != null;
}
} catch (Exception e) {
DoDebug("Something went wrong with TaskService, checking if ACC starts with Windows (Task Scheduler); " + e.Message);
}
} else {
try {
RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
var theVal = rk.GetValue(appName);
if (theVal != null) {
return true;
} else {
return false;
}
} catch {
DoDebug("Failed to get ACC start with windows state (Registry)");
return false;
}
}
return false;
}
19
View Source File : MainProgram.cs
License : MIT License
Project Creator : AlbertMN
License : MIT License
Project Creator : AlbertMN
public static bool ApplicationInstalled(string c_name) {
string displayName;
string registryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
RegistryKey key = Registry.LocalMachine.OpenSubKey(registryKey);
if (key != null) {
foreach (RegistryKey subkey in key.GetSubKeyNames().Select(keyName => key.OpenSubKey(keyName))) {
displayName = subkey.GetValue("DisplayName") as string;
if (displayName != null && displayName.Contains(c_name)) {
return true;
}
}
key.Close();
}
registryKey = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
key = Registry.LocalMachine.OpenSubKey(registryKey);
if (key != null) {
foreach (RegistryKey subkey in key.GetSubKeyNames().Select(keyName => key.OpenSubKey(keyName))) {
displayName = subkey.GetValue("DisplayName") as string;
if (displayName != null && displayName.Contains(c_name)) {
return true;
}
}
key.Close();
}
return false;
}
19
View Source File : SystemUtils.cs
License : MIT License
Project Creator : AlexanderPro
License : MIT License
Project Creator : AlexanderPro
public static string GetDefaultBrowserModuleName()
{
var browserName = "iexplore.exe";
using (var userChoiceKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\Shell\\replacedociations\\Urlreplacedociations\\http\\UserChoice"))
{
if (userChoiceKey == null)
{
return browserName;
}
var progIdValue = userChoiceKey.GetValue("Progid");
if (progIdValue == null)
{
return browserName;
}
var progId = progIdValue.ToString();
var path = progId + "\\shell\\open\\command";
using (var pathKey = Registry.ClreplacedesRoot.OpenSubKey(path))
{
if (pathKey == null)
{
return browserName;
}
try
{
path = pathKey.GetValue(null).ToString().ToLower().Replace("\"", "");
const string exeSuffix = ".exe";
if (!path.EndsWith(exeSuffix))
{
path = path.Substring(0, path.LastIndexOf(exeSuffix, StringComparison.Ordinal) + exeSuffix.Length);
}
return path;
}
catch
{
return browserName;
}
}
}
}
19
View Source File : StartUpManager.cs
License : MIT License
Project Creator : AlexanderPro
License : MIT License
Project Creator : AlexanderPro
public static bool IsInStartup(string keyName, string replacedemblyLocation)
{
using (var key = Registry.CurrentUser.OpenSubKey(RUN_LOCATION, true))
{
if (key == null) return false;
var value = (string)key.GetValue(keyName);
if (string.IsNullOrEmpty(value)) return false;
var result = (value == replacedemblyLocation);
return result;
}
}
19
View Source File : AutoStarter.cs
License : MIT License
Project Creator : AlexanderPro
License : MIT License
Project Creator : AlexanderPro
public static bool IsAutoStartByRegisterEnabled(string keyName, string replacedemblyLocation)
{
using (var key = Registry.CurrentUser.OpenSubKey(RUN_LOCATION))
{
if (key == null) return false;
var value = (string)key.GetValue(keyName);
if (string.IsNullOrEmpty(value)) return false;
var result = (value == replacedemblyLocation);
return result;
}
}
19
View Source File : HeatmasterGroup.cs
License : MIT License
Project Creator : AlexGyver
License : MIT License
Project Creator : AlexGyver
private static string[] GetRegistryPortNames() {
List<string> result = new List<string>();
string[] paths = { "", "&MI_00" };
try {
foreach (string path in paths) {
RegistryKey key = Registry.LocalMachine.OpenSubKey(
@"SYSTEM\CurrentControlSet\Enum\USB\VID_10C4&PID_EA60" + path);
if (key != null) {
foreach (string subKeyName in key.GetSubKeyNames()) {
RegistryKey subKey =
key.OpenSubKey(subKeyName + "\\" + "Device Parameters");
if (subKey != null) {
string name = subKey.GetValue("PortName") as string;
if (name != null && !result.Contains(name))
result.Add(name);
}
}
}
}
} catch (SecurityException) { }
return result.ToArray();
}
19
View Source File : MainWindow.xaml.cs
License : Apache License 2.0
Project Creator : AlexWan
License : Apache License 2.0
Project Creator : AlexWan
private bool CheckDotNetVersion()
{
using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\"))
{
if (ndpKey == null)
{
return false;
}
int releaseKey = Convert.ToInt32(ndpKey.GetValue("Release"));
if (releaseKey >= 393295)
{
//"4.6 or later";
return true;
}
if ((releaseKey >= 379893))
{
//"4.5.2 or later";
return true;
}
if ((releaseKey >= 378675))
{
//"4.5.1 or later";
return true;
}
if ((releaseKey >= 378389))
{
MessageBox.Show(OsLocalization.MainWindow.Message4);
return false;
}
MessageBox.Show(OsLocalization.MainWindow.Message4);
return false;
}
}
19
View Source File : PulseLogPrivesc.cs
License : Apache License 2.0
Project Creator : AlmondOffSec
License : Apache License 2.0
Project Creator : AlmondOffSec
public static string GetPulseCommandLineFromRegistry(string regKey, string value)
{
try
{
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(regKey))
{
if (key != null)
{
Object o = key.GetValue(value);
if (o != null) {
string v = o as String;
return v.Remove(v.IndexOf(PulseRunArg)).Trim();
}
}
}
}
catch {}
return null;
}
19
View Source File : DefaultYoloSystemValidator.cs
License : MIT License
Project Creator : AlturosDestinations
License : MIT License
Project Creator : AlturosDestinations
private bool IsMicrosoftVisualCPlusPlus2017Available()
{
//Detect if Visual C++ Redistributable for Visual Studio is installed
//https://stackoverflow.com/questions/12206314/detect-if-visual-c-redistributable-for-visual-studio-2012-is-installed/
var checkKeys = new Dictionary<string, string>
{
{ @"Installer\Dependencies\,,amd64,14.0,bundle", "Microsoft Visual C++ 2017 Redistributable (x64)" },
{ @"Installer\Dependencies\VC,redist.x64,amd64,14.16,bundle", "Microsoft Visual C++ 2017 Redistributable (x64)" },
{ @"Installer\Dependencies\VC,redist.x64,amd64,14.20,bundle", "Microsoft Visual C++ 2015-2019 Redistributable (x64)" },
{ @"Installer\Dependencies\VC,redist.x64,amd64,14.21,bundle", "Microsoft Visual C++ 2015-2019 Redistributable (x64)" },
{ @"Installer\Dependencies\VC,redist.x64,amd64,14.22,bundle", "Microsoft Visual C++ 2015-2019 Redistributable (x64)" },
{ @"Installer\Dependencies\VC,redist.x64,amd64,14.23,bundle", "Microsoft Visual C++ 2015-2019 Redistributable (x64)" },
{ @"Installer\Dependencies\VC,redist.x64,amd64,14.24,bundle", "Microsoft Visual C++ 2015-2019 Redistributable (x64)" },
{ @"Installer\Dependencies\VC,redist.x64,amd64,14.25,bundle", "Microsoft Visual C++ 2015-2019 Redistributable (x64)" },
{ @"Installer\Dependencies\VC,redist.x64,amd64,14.26,bundle", "Microsoft Visual C++ 2015-2019 Redistributable (x64)" }
};
foreach (var checkKey in checkKeys)
{
using (var registryKey = Registry.ClreplacedesRoot.OpenSubKey(checkKey.Key, false))
{
if (registryKey == null)
{
continue;
}
var displayName = registryKey.GetValue("DisplayName") as string;
if (string.IsNullOrEmpty(displayName))
{
continue;
}
if (displayName.StartsWith(checkKey.Value, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
}
return false;
}
19
View Source File : frmMain.cs
License : GNU General Public License v3.0
Project Creator : amakvana
License : GNU General Public License v3.0
Project Creator : amakvana
private bool DependenciesInstalled()
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\DevDiv\VC\Servicing\14.0\RuntimeMinimum", false);
return (key != null) && key.GetValue("Version").ToString().StartsWith("14");
}
19
View Source File : EpicGameFinder.cs
License : MIT License
Project Creator : amazingalek
License : MIT License
Project Creator : amazingalek
public override string FindGamePath()
{
var key = Registry.LocalMachine.OpenSubKey(RegistryPath);
var appDataPath = (string)key?.GetValue(RegistryName);
if (string.IsNullOrEmpty(appDataPath))
{
Writer.WriteLine("EGS not found in Registry.");
return null;
}
var manifestsPath = $"{appDataPath}{ManifestsFolder}";
if (!Directory.Exists(manifestsPath))
{
Writer.WriteLine($"EGS manifests folder not found: {manifestsPath}");
return null;
}
var manifestPaths = Directory.GetFiles(manifestsPath, ManifestPattern, SearchOption.TopDirectoryOnly);
foreach (var manifestPath in manifestPaths)
{
var json = File.ReadAllText(manifestPath);
var epicManifest = JsonConvert.DeserializeObject<EpicManifest>(json);
if (epicManifest.InstallLocation.Contains(ManifestGameName) && IsValidGamePath(epicManifest.InstallLocation))
{
return epicManifest.InstallLocation;
}
}
Writer.WriteLine("Game not found in EGS.");
return null;
}
19
View Source File : SteamGameFinder.cs
License : MIT License
Project Creator : amazingalek
License : MIT License
Project Creator : amazingalek
public override string FindGamePath()
{
var key = Registry.CurrentUser.OpenSubKey(RegistryPath);
var steamPath = (string)key?.GetValue(RegistryName);
if (string.IsNullOrEmpty(steamPath))
{
Writer.WriteLine("Steam not found in Registry.");
return null;
}
var defaultLocation = $"{steamPath}/{GameLocation}";
if (IsValidGamePath(defaultLocation))
{
return defaultLocation;
}
var libraryFoldersFile = $"{steamPath}/{LibraryFoldersPath}";
if (!File.Exists(libraryFoldersFile))
{
Writer.WriteLine($"Steam library folders file not found: {libraryFoldersFile}");
return null;
}
var libraryFoldersContent = File.ReadAllText(libraryFoldersFile);
var libraryFoldersVdf = VdfConvert.Deserialize(libraryFoldersContent);
for (var i = 0; i < MaxLibraryCount; i++)
{
var libraryName = i.ToString();
var libraryBlock = libraryFoldersVdf.Value[libraryName];
if (libraryBlock is null)
{
continue;
}
var token = libraryBlock.Children().First().ToString();
var libraryPath = token.Substring(8, token.Length - 9);
if (string.IsNullOrEmpty(libraryPath))
{
continue;
}
var gamePath = $"{libraryPath}/{GameLocation}";
if (IsValidGamePath(gamePath))
{
return gamePath;
}
}
Writer.WriteLine("Game not found in Steam.");
return null;
}
19
View Source File : HTTPController.cs
License : MIT License
Project Creator : AmazingDM
License : MIT License
Project Creator : AmazingDM
private void RecordPrevious()
{
try
{
var registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings");
if (registry == null)
throw new Exception();
prevPAC = registry.GetValue("AutoConfigURL")?.ToString() ?? "";
prevHTTP = registry.GetValue("ProxyServer")?.ToString() ?? "";
prevBypreplaced = registry.GetValue("ProxyOverride")?.ToString() ?? "";
prevEnabled = registry.GetValue("ProxyEnable")?.Equals(1) ?? false; // HTTP Proxy Enabled
if (prevHTTP == $"127.0.0.1:{Global.Settings.HTTPLocalPort}")
{
prevEnabled = false;
prevHTTP = "";
}
if (prevPAC != "")
prevEnabled = true;
}
catch
{
prevEnabled = false;
prevPAC = prevHTTP = prevBypreplaced = "";
}
}
19
View Source File : ResourceRef.cs
License : GNU General Public License v3.0
Project Creator : Amebis
License : GNU General Public License v3.0
Project Creator : Amebis
public bool ReadRegistry(RegistryKey key, string name)
{
if (key.GetValue(name) is string v)
{
Uri = !string.IsNullOrEmpty(v) ? new Uri(replacedemblyUri, v) : null;
var pk = new MinisignPublicKeyDictionary();
if (pk.ReadRegistry(key, name + "PublicKeys"))
PublicKeys = pk;
return true;
}
return false;
}
19
View Source File : MinisignPublicKeyDictionary.cs
License : GNU General Public License v3.0
Project Creator : Amebis
License : GNU General Public License v3.0
Project Creator : Amebis
public bool ReadRegistry(RegistryKey key, string name)
{
if (key.GetValue(name) is string[] v)
{
foreach (var str in v)
Add(str);
return true;
}
return false;
}
19
View Source File : ApplicationSettingsBaseEx.cs
License : GNU General Public License v3.0
Project Creator : Amebis
License : GNU General Public License v3.0
Project Creator : Amebis
protected bool GetValue(string name, out uint value)
{
if (Key?.GetValue(name) is int v)
{
value = (uint)v;
return true;
}
value = default;
return false;
}
19
View Source File : ApplicationSettingsBaseEx.cs
License : GNU General Public License v3.0
Project Creator : Amebis
License : GNU General Public License v3.0
Project Creator : Amebis
protected bool GetValue(string name, out string value)
{
if (Key?.GetValue(name) is string v)
{
value = v;
return true;
}
value = default;
return false;
}
19
View Source File : ApplicationSettingsBaseEx.cs
License : GNU General Public License v3.0
Project Creator : Amebis
License : GNU General Public License v3.0
Project Creator : Amebis
protected bool GetValue(string name, out string[] value)
{
if (Key?.GetValue(name) is string[] v)
{
value = v;
return true;
}
value = default;
return false;
}
19
View Source File : ApplicationSettingsBaseEx.cs
License : GNU General Public License v3.0
Project Creator : Amebis
License : GNU General Public License v3.0
Project Creator : Amebis
protected bool GetValue(string name, out StringCollection value)
{
if (Key?.GetValue(name) is string[] v)
{
value = new StringCollection();
value.AddRange(v);
return true;
}
value = default;
return false;
}
19
View Source File : SelfUpdatePromptPage.cs
License : GNU General Public License v3.0
Project Creator : Amebis
License : GNU General Public License v3.0
Project Creator : Amebis
public void CheckForUpdates()
{
try
{
Parallel.ForEach(new List<Action>()
{
() =>
{
// Get self-update.
var res = Properties.SettingsEx.Default.SelfUpdateDiscovery;
Trace.TraceInformation("Downloading self-update JSON discovery from {0}...", res.Uri.AbsoluteUri);
var obj = Properties.Settings.Default.ResponseCache.GetSeq(res, Window.Abort.Token);
var repoVersion = new Version((string)obj["version"]);
Trace.TraceInformation("Online version: {0}", repoVersion.ToString());
Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => {
AvailableVersion = repoVersion;
Changelog = eduJSON.Parser.GetValue(obj, "changelog_uri", out string changelogUri) ? new Uri(changelogUri) : null;
Wizard.SelfUpdateProgressPage.DownloadUris = new List<Uri>(((List<object>)obj["uri"]).Select(uri => new Uri(res.Uri, (string)uri)));
Wizard.SelfUpdateProgressPage.Hash = ((string)obj["hash-sha256"]).FromHexToBin();
Wizard.SelfUpdateProgressPage.Arguments = eduJSON.Parser.GetValue(obj, "arguments", out string installerArguments) ? installerArguments : null;
}));
},
() =>
{
// Evaluate installed products.
Version productVersion = null;
var productId = Properties.Settings.Default.SelfUpdateBundleId.ToUpperInvariant();
Trace.TraceInformation("Evaluating installed products...");
using (var hklmKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
using (var uninstallKey = hklmKey.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", false))
{
foreach (var productKeyName in uninstallKey.GetSubKeyNames())
{
Window.Abort.Token.ThrowIfCancellationRequested();
using (var productKey = uninstallKey.OpenSubKey(productKeyName))
{
var bundleUpgradeCode = productKey.GetValue("BundleUpgradeCode");
if ((bundleUpgradeCode is string bundleUpgradeCodeString && bundleUpgradeCodeString.ToUpperInvariant() == productId ||
bundleUpgradeCode is string[] bundleUpgradeCodeArray && bundleUpgradeCodeArray.FirstOrDefault(code => code.ToUpperInvariant() == productId) != null) &&
productKey.GetValue("BundleVersion") is string bundleVersionString)
{
// Our product entry found.
productVersion = new Version(productKey.GetValue("DisplayVersion") is string displayVersionString ? displayVersionString : bundleVersionString);
Trace.TraceInformation("Installed version: {0}", productVersion.ToString());
break;
}
}
}
}
Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => { InstalledVersion = productVersion; }));
},
},
action =>
{
Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.TaskCount++));
try { action(); }
finally { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.TaskCount--)); }
});
}
catch (AggregateException ex)
{
var nonCancelledException = ex.InnerExceptions.Where(innerException => !(innerException is OperationCanceledException));
if (nonCancelledException.Any())
throw new AggregateException(Resources.Strings.ErrorSelfUpdateDetection, nonCancelledException.ToArray());
throw new OperationCanceledException();
}
//// Mock the values for testing.
//InstalledVersion = new Version(1, 0);
//Properties.Settings.Default.SelfUpdateLastReminder = DateTime.MinValue;
try
{
if (new Version(Properties.Settings.Default.SelfUpdateLastVersion) == AvailableVersion &&
(Properties.Settings.Default.SelfUpdateLastReminder == DateTime.MaxValue ||
(DateTime.UtcNow - Properties.Settings.Default.SelfUpdateLastReminder).TotalDays < 3))
{
// We already prompted user for this version.
// Either user opted not to be reminded of this version update again,
// or it has been less than three days since the last prompt.
Trace.TraceInformation("Update deferred by user choice.");
return;
}
}
catch { }
if (InstalledVersion == null)
{
// Nothing to update.
Trace.TraceInformation("Product not installed or version could not be determined.");
return; // Quit self-updating.
}
if (AvailableVersion <= InstalledVersion)
{
// Product already up-to-date.
Trace.TraceInformation("Update not required.");
return;
}
// We're in the background thread - raise the prompt event via dispatcher.
Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
{
if (Wizard.NavigateTo.CanExecute(this))
{
Properties.Settings.Default.SelfUpdateLastVersion = AvailableVersion.ToString();
Properties.Settings.Default.SelfUpdateLastReminder = DateTime.UtcNow;
Wizard.NavigateTo.Execute(this);
}
}));
}
19
View Source File : CheckForUpdates.cs
License : Apache License 2.0
Project Creator : AmpScm
License : Apache License 2.0
Project Creator : AmpScm
public override void OnExecute(CommandEventArgs e)
{
if (e.Argument != null)
{
ShowUpdate(e);
return;
}
int interval = 24 * 6; // 6 days
IAnkhConfigurationService config = e.GetService<IAnkhConfigurationService>();
if (config.Instance.DisableUpdateCheck)
return;
using (RegistryKey rk = config.OpenUserInstanceKey("UpdateCheck"))
{
object value = rk.GetValue("Interval");
if (value is int)
{
interval = (int)value;
if (interval <= 0)
return;
}
}
Version version = GetCurrentVersion(e.Context);
Version osVersion = Environment.OSVersion.Version;
StringBuilder sb = new StringBuilder();
sb.Append("http://svc.ankhsvn.net/svc/");
if (IsDevVersion())
sb.Append("dev/");
sb.Append("update-info/");
sb.Append(version.ToString(2));
sb.Append(".xml");
sb.Append("?av=");
sb.Append(version);
sb.Append("&vs=");
sb.Append(VSVersion.FullVersion);
sb.Append("&os=");
sb.Append(osVersion);
if (IsDevVersion())
sb.Append("&dev=1");
sb.AppendFormat(CultureInfo.InvariantCulture, "&iv={0}", interval);
int x = 0;
// Create some hashcode that is probably constant and unique for all users
// using the same IP address, but not translatable to a single user
try
{
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
{
string type = ni.NetworkInterfaceType.ToString();
if (type.Contains("Ethernet") || type.Contains("Wireless"))
x ^= ni.GetPhysicalAddress().GetHashCode();
}
}
catch { }
sb.AppendFormat(CultureInfo.InvariantCulture, "&xx={0}&pc={1}", x, Environment.ProcessorCount);
try
{
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP"))
{
if (rk != null)
{
sb.Append("&dn=");
Regex re = new Regex("^[vV]([0-9]+\\.[0-9]+)(\\.[0-9]+)*", RegexOptions.Singleline);
bool first = true;
HybridCollection<string> vers = new HybridCollection<string>();
foreach (string s in rk.GetSubKeyNames())
{
Match m = re.Match(s);
if (m.Success)
{
string v = m.Groups[1].Value;
if (vers.Contains(v))
continue;
vers.Add(v);
if (first)
first = false;
else
sb.Append(',');
sb.Append(v);
}
}
}
}
}
catch
{ }
WebRequest wr;
try
{
wr = WebRequest.Create(new Uri(sb.ToString()));
}
catch (System.Configuration.ConfigurationException)
{
// The global .Net or Visual Studio configuration probably contains an invalid (proxy) configuration
return; // Not our problem
}
HttpWebRequest hwr = wr as HttpWebRequest;
if (hwr != null)
{
hwr.AllowAutoRedirect = true;
hwr.AllowWriteStreamBuffering = true;
hwr.UserAgent = string.Format("AnkhSVN/{0} VisualStudio/{1} Windows/{2}", version, VSVersion.FullVersion, osVersion);
}
try
{
wr.BeginGetResponse(OnResponse, wr);
}
catch (NotSupportedException)
{ /* Raised when an invalid proxy server setting is set */ }
}
19
View Source File : CheckForUpdates.cs
License : Apache License 2.0
Project Creator : AmpScm
License : Apache License 2.0
Project Creator : AmpScm
private void OnResponse(IAsyncResult ar)
{
IAnkhConfigurationService config = Context.GetService<IAnkhConfigurationService>();
bool failed = true;
string tag = null;
try
{
WebRequest rq = ((WebRequest)ar.AsyncState);
WebResponse wr;
try
{
wr = rq.EndGetResponse(ar);
}
catch (WebException e)
{
HttpWebResponse hwr = e.Response as HttpWebResponse;
if (hwr != null)
{
if (hwr.StatusCode == HttpStatusCode.NotFound)
{
failed = false;
return; // File not found.. Update info not yet or no longer available
}
}
return;
}
catch
{
return;
}
if (wr.ContentLength > 65536) // Not for us.. We expect a few hundred bytes max
return;
string body;
using (Stream s = wr.GetResponseStream())
using (StreamReader sr = new StreamReader(s))
{
body = sr.ReadToEnd().Trim();
}
if (string.IsNullOrEmpty(body))
{
failed = false;
return;
}
if (body[0] != '<' || body[body.Length - 1] != '>')
return; // No valid xml or empty
failed = false;
XmlDoreplacedent doc = new XmlDoreplacedent();
doc.LoadXml(body);
string replacedle = NodeText(doc, "/u/i/t");
string header = NodeText(doc, "/u/i/h") ?? replacedle;
string description = NodeText(doc, "/u/i/d");
string url = NodeText(doc, "/u/i/u");
string urltext = NodeText(doc, "/u/i/l");
string version = NodeText(doc, "/u/i/v");
string newVersion = NodeText(doc, "/u/i/n") ?? version;
tag = NodeText(doc, "/u/g");
if (!string.IsNullOrEmpty(replacedle) && !string.IsNullOrEmpty(description))
{
if (!string.IsNullOrEmpty(version))
{
Version v = new Version(version);
if (v <= GetCurrentVersion(Context))
return;
}
if (!string.IsNullOrEmpty(tag))
{
using (RegistryKey rk = config.OpenUserInstanceKey("UpdateCheck"))
{
string pTag = rk.GetValue("SkipTag") as string;
if (pTag == tag)
return;
}
}
IAnkhCommandService cs = Context.GetService<IAnkhCommandService>();
cs.PostExecCommand(AnkhCommand.CheckForUpdates,
new string[] { replacedle, header, description, url, urltext, version, newVersion, tag });
}
}
finally
{
using (RegistryKey rk = config.OpenUserInstanceKey("UpdateCheck"))
{
object fails = rk.GetValue("Fails", 0);
rk.DeleteValue("LastCheck", false);
rk.DeleteValue("LastVersion", false);
rk.DeleteValue("FailedChecks", false);
rk.SetValue("LastCheck", DateTime.UtcNow.Ticks);
rk.SetValue("LastVersion", GetCurrentVersion(Context).ToString());
if (tag != null)
rk.SetValue("LastTag", tag);
else
rk.DeleteValue("LastTag", false);
if (failed)
{
int f = 0;
if (fails is int)
f = (int)fails + 1;
rk.SetValue("FailedChecks", f);
}
}
}
}
See More Examples