public bool LoadEmulatorSettings() { RegistryKey reg = Registry.LocalMachine; try { object location = null; var drives = DriveInfo.GetDrives(); foreach (var d in drives) { if (File.Exists(d.Name + @"Program Files\Microvirt\MEmu\MEmu.exe")) { location = d.Name + @"Program Files\Microvirt"; } } if (location == null) { //We will try getting running processes as user might helped us opened it foreach (var process in Process.GetProcesses().Where(x => x.ProcessName.Contains("MEmu"))) { if (File.Exists(process.MainModule.FileName) && process.MainModule.FileName.EndsWith("MEmu.exe")) { location = process.MainModule.FileName.Replace(@"\MEmu\MEmu.exe", ""); if (BotCore.Is64BitOperatingSystem()) { RegistryKey r = reg.OpenSubKey("SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MEmu"); if (r == null) { //MEmu didnt have this registered, lets do it for next load we will able to get file easily r = reg.CreateSubKey("SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MEmu"); r.SetValue("InstallLocation", location); } } else { RegistryKey r = reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MEmu"); if (r == null) { //MEmu didnt have this registered, lets do it for next load we will able to get file easily r = reg.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MEmu"); r.SetValue("InstallLocation", location); } } break; } } } if (location == null) { RegistryKey r = reg.OpenSubKey("SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MEmu"); if (r == null) { r = reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MEmu"); } if (r == null) { return(false); } location = r.GetValue("InstallLocation"); if (location == null) { location = r.GetValue("DisplayIcon"); if (location != null) { location = location.ToString().Remove(location.ToString().LastIndexOf("\\")); } } } //Found all the path of MEmu if (location != null) { var path = location.ToString().Replace("\0", ""); if (Directory.Exists(path)) { Variables.VBoxManagerPath = path + @"\MEmuHyperv\MEmuManage.exe"; ProcessStartInfo fetch = new ProcessStartInfo(Variables.VBoxManagerPath); if (Variables.Instance.Length > 0) { fetch.Arguments = "showvminfo " + Variables.Instance; } else { fetch.Arguments = "showvminfo MEmu"; } fetch.CreateNoWindow = true; fetch.RedirectStandardOutput = true; fetch.UseShellExecute = false; do { Process fetching = Process.Start(fetch); string result = fetching.StandardOutput.ReadToEnd(); string[] splitted = result.Split('\n'); foreach (var s in splitted) { if (s.Contains("Name: 'download', Host path:")) { string regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); Regex re = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch))); path = s.ToLower().Replace("name: 'download', host path: '", "").Replace("' (machine mapping), writable", ""); path = re.Replace(path, "\\"); path = path.Replace("\\\\", ":\\"); Variables.SharedPath = path; if (!Directory.Exists(Variables.SharedPath)) { MessageBox.Show("共享路径包含不允许字符,请重新设置模拟器的共享路径!"); Environment.Exit(0); } } else if (s.Contains("name = ADB")) { var port = s.Substring(s.IndexOf("port = ") + 7, 5).Replace(" ", ""); Variables.AdbIpPort = "127.0.0.1:" + port; } } }while (Variables.SharedPath == null || Variables.AdbIpPort == null); Variables.AndroidSharedPath = "/sdcard/Download/"; Variables.ClickPointMultiply = 1; return(true); } } } catch (Exception ex) { Variables.AdvanceLog(ex.ToString()); } return(false); }
public bool LoadEmulatorSettings() { try { RegistryKey reg; string path; //Read display icon if (BotCore.Is64BitOperatingSystem()) { reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\iToolsAVM\"); } else { reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\iToolsAVM\"); } path = reg.GetValue("DisplayIcon").ToString(); path = path.Remove(path.LastIndexOf("\\")); if (File.Exists(path + "\\iToolsAVM.exe")) { emulatorpath = path; } else { return(false); } reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Oracle\\VirtualBox\\"); if (reg != null) { Variables.VBoxManagerPath = reg.GetValue("InstallDir").ToString() + "VBoxManage.exe"; } else { Variables.VBoxManagerPath = "C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe"; } if (!File.Exists(Variables.VBoxManagerPath)) { return(false); } ProcessStartInfo fetch = new ProcessStartInfo(Variables.VBoxManagerPath); if (Variables.Instance.Length > 0) { fetch.Arguments = "showvminfo " + Variables.Instance; } else { fetch.Arguments = "showvminfo iToolsVM"; } fetch.CreateNoWindow = true; fetch.RedirectStandardOutput = true; fetch.UseShellExecute = false; Process fetching = Process.Start(fetch); string result = fetching.StandardOutput.ReadToEnd(); string[] splitted = result.Split('\n'); foreach (var s in splitted) { if (s.Contains("name = ADB_PORT")) { var port = s.Substring(s.IndexOf("port = ") + 7, 5).Replace(" ", ""); Variables.AdbIpPort = "127.0.0.1:" + port; } } Variables.SharedPath = emulatorpath + "\\UsersCommon\\"; Variables.AndroidSharedPath = "/data/iToolsVMShare/"; return(true); } catch (Exception ex) { Variables.AdvanceLog(ex.ToString()); } return(false); }
public bool LoadEmulatorSettings() { RegistryKey reg = Registry.LocalMachine; string path; var r = reg.OpenSubKey(@"SOFTWARE\BigNox\VirtualBox\"); if (r != null) { try { var result = r.GetValue("InstallDir"); if (result != null) { path = result.ToString(); if (Directory.Exists(path)) { NoxFile = path; Variables.VBoxManagerPath = GetRTPath() + "BigNoxVMMgr.exe"; InitNox(); return(true); } } } catch (Exception ex) { Variables.AdvanceLog(ex.ToString()); } } if (BotCore.Is64BitOperatingSystem()) { r = reg.OpenSubKey("SOFTWARE\\Wow6432Node\\DuoDianOnline\\SetupInfo\\"); if (r != null) { try { var result = r.GetValue("InstallPath"); if (result != null) { path = result.ToString(); if (Directory.Exists(path)) { NoxFile = path; Variables.VBoxManagerPath = GetRTPath() + "BigNoxVMMgr.exe"; InitNox(); return(true); } } } catch { } } } else { r = reg.OpenSubKey("SOFTWARE\\DuoDianOnline\\SetupInfo\\"); if (r != null) { try { var result = r.GetValue("InstallPath"); if (result != null) { path = result.ToString(); if (Directory.Exists(path)) { NoxFile = path + "\\bin\\Nox.exe"; Variables.VBoxManagerPath = GetRTPath() + "BigNoxVMMgr.exe"; InitNox(); return(true); } } } catch { } } } return(false); }