コード例 #1
0
        private void UpdateCPProcessID(DataGrid dgrid, Process process, int lcid, int selectedIndex, string appletTitle)
        {
            int pid = process.Id;
            var cp = (ContentPresenter)dgrid.GetCell(selectedIndex, 3).Content;
            TextBlock tbLaunchName = (TextBlock)cp.ContentTemplate.FindName("tbLaunchName", cp);
            tbLaunchName.Tag = pid;
            listCPLanguages.FirstOrDefault(lng => lng.UniversalID == lcid).PID = pid.ToString();
            Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\ControlPanelApplet\\" + process.Id.ToString(), "AppletTitle", appletTitle, RegistryValueKind.String);
            Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\ControlPanelApplet\\" + process.Id.ToString(), "LCID", lcid, RegistryValueKind.String);
            Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\ControlPanelApplet\\" + process.Id.ToString(), "SessionID", process.SessionId.ToString(), RegistryValueKind.String);
            Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\ControlPanelApplet\\" + process.Id.ToString(), "UserName", WindowsIdentity.GetCurrent().Name, RegistryValueKind.String);

            if (!dictCurrentCPInfo.ContainsKey(pid))
            {
                CPAppletInfo info = new CPAppletInfo();
                info.LCID = lcid;
                info.ProcessID = pid;
                info.SessionID = process.SessionId;
                info.UserName = WindowsIdentity.GetCurrent().Name;
                info.AppletTitle = appletTitle;
                dictCurrentCPInfo.Add(pid, info);
            }
        }
コード例 #2
0
 private CPAppletInfo GetCPAppletInfo(int pid)
 {
     CPAppletInfo info = new CPAppletInfo();
     info.ProcessID = pid;
     info.SessionID = Convert.ToInt32(Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\ControlPanelApplet\\" + pid.ToString()).GetValue("SessionID"));
     info.LCID = Convert.ToInt32(Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\ControlPanelApplet\\" + pid.ToString()).GetValue("LCID"));
     info.UserName = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\ControlPanelApplet\\" + pid.ToString()).GetValue("UserName").ToString();
     info.AppletTitle = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\" + Settings.RegistrySettingName + "\\ControlPanelApplet\\" + pid.ToString()).GetValue("AppletTitle").ToString();
     return info;
 }