private void UpdateSCProcessID(DataGrid dgrid, Process process, int lcid, bool isDebugConsole, int selectedIndex, bool isNewVersion) { int pid = process.Id; int columnIndex = isNewVersion ? 3 : 4; string tbLaunchNameStr = isNewVersion ? "tbLaunchNewVersionName" : "tbLaunchOldVersionName"; var cp = (ContentPresenter)dgrid.GetCell(selectedIndex, columnIndex).Content; TextBlock tbLaunchName = (TextBlock)cp.ContentTemplate.FindName(tbLaunchNameStr, cp); tbLaunchName.Tag = pid; if (isNewVersion) { listClientLanguages.FirstOrDefault(lng => lng.UniversalID == lcid).PIDNewVersion = pid.ToString(); } else { listClientLanguages.FirstOrDefault(lng => lng.UniversalID == lcid).PIDOldVersion = pid.ToString(); } Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\SoftwareCenter\\" + process.Id.ToString(), "LCID", lcid, RegistryValueKind.String); Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\SoftwareCenter\\" + process.Id.ToString(), "IsDebugConsole", isDebugConsole, RegistryValueKind.String); Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\SoftwareCenter\\" + process.Id.ToString(), "SessionID", process.SessionId.ToString(), RegistryValueKind.String); Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\SoftwareCenter\\" + process.Id.ToString(), "UserName", WindowsIdentity.GetCurrent().Name, RegistryValueKind.String); Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\SoftwareCenter\\" + process.Id.ToString(), "IsNewVersion", isNewVersion, RegistryValueKind.String); if (!dictCurrentSCInfo.ContainsKey(pid)) { SoftwareCenterInfo info = new SoftwareCenterInfo(); info.IsDebugConsole = isDebugConsole; info.IsNewVersion = isNewVersion; info.LCID = lcid; info.ProcessID = pid; info.SessionID = process.SessionId; info.UserName = WindowsIdentity.GetCurrent().Name; dictCurrentSCInfo.Add(pid, info); } }
private SoftwareCenterInfo GetSoftwareCenterInfo(int pid) { SoftwareCenterInfo info = new SoftwareCenterInfo(); info.ProcessID = pid; info.SessionID = Convert.ToInt32(Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\SoftwareCenter\\" + pid.ToString()).GetValue("SessionID")); info.LCID = Convert.ToInt32(Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\SoftwareCenter\\" + pid.ToString()).GetValue("LCID")); info.UserName = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\SoftwareCenter\\" + pid.ToString()).GetValue("UserName").ToString(); info.IsDebugConsole = Convert.ToBoolean(Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\SoftwareCenter\\" + pid.ToString()).GetValue("IsDebugConsole")); info.IsNewVersion = Convert.ToBoolean(Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\SoftwareCenter\\" + pid.ToString()).GetValue("IsNewVersion")); return info; }