Exemplo n.º 1
0
        private void Change_Click(object sender, RoutedEventArgs e)
        {
            SIDName seleted    = (SIDName)dgList.SelectedItem;
            Process CmdProcess = new Process();

            CmdProcess.StartInfo.FileName               = "CheckNetIsolation.exe";
            CmdProcess.StartInfo.CreateNoWindow         = true;  // 不创建新窗口
            CmdProcess.StartInfo.UseShellExecute        = false; //不启用shell启动进程
            CmdProcess.StartInfo.RedirectStandardInput  = true;  // 重定向输入
            CmdProcess.StartInfo.RedirectStandardOutput = true;  // 重定向标准输出    \
            CmdProcess.StartInfo.RedirectStandardError  = false; // 重定向错误输出
            if (seleted.IsUsing)
            {
                CmdProcess.StartInfo.Arguments = "LoopBackExempt -d -p=" + seleted.SID;
            }
            else
            {
                CmdProcess.StartInfo.Arguments = "LoopBackExempt -a -p=" + seleted.SID;
            }
            CmdProcess.Start();                                         //执行
            string returnvalue = CmdProcess.StandardOutput.ReadToEnd(); //获取返回值

            Debug.WriteLine("Progres Return:\n" + returnvalue);
            File.WriteAllText("CheckNetIsolationReurn.temp", returnvalue);
            CmdProcess.WaitForExit();//等待程序执行完退出进程
            seleted.IsUsing = !seleted.IsUsing;
            MenuItem_Click();
        }
Exemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string str = tbSearchText.Text.ToLower();
            bool   ret = false;

            for (int i = 0; i < dgList.Items.Count; i++)
            {
                SIDName item = (SIDName)dgList.Items[i];
                if (cbSearchSID.IsChecked == true)
                {
                    ret = item.SID.ToLower().Contains(str);
                }
                if (cbSearchM.IsChecked == true)
                {
                    ret = item.Moniker.ToLower().Contains(str);
                }
                if (cbSearchDN.IsChecked == true)
                {
                    ret = item.DisplayName.ToLower().Contains(str);
                }
                if (ret)
                {
                    dgList.SelectedIndex = i;
                    dgList.ScrollIntoView(dgList.SelectedItem);
                    dgList.UpdateLayout();
                    MessageBoxResult msgret = MessageBox.Show(
                        "SID\t\t: " + item.SID +
                        "\nMoniker\t\t: " + item.Moniker +
                        "\nDisplayName\t: " + item.DisplayName +
                        "\n\t\t\tContinued?",
                        "Find a Result!", MessageBoxButton.YesNo
                        );
                    switch (msgret)
                    {
                    case MessageBoxResult.None:
                        break;

                    case MessageBoxResult.OK:
                    case MessageBoxResult.Yes:
                        continue;

                    case MessageBoxResult.Cancel:
                    case MessageBoxResult.No:
                        miScan_Click();
                        return;

                    default:
                        break;
                    }
                }
                if (i == dgList.Items.Count - 1)
                {
                    MessageBox.Show("Cannot Found", "Not Found");
                    miScan_Click();
                }
            }
        }