Beispiel #1
0
        private void ChckSrvc()
        {
            var sc = new ServiceController(@"Dnscache");

            if (sc.Status == ServiceControllerStatus.Running)
            {
                return;
            }
            MainWindows.CmdExe(@"sc start Dnscache");
            Notification(@"В фонов режиме была запущена служба DNS");
        }
Beispiel #2
0
        private void Button2_Click(object sender, EventArgs e)
        {
            var audio = new SoundPlayer(Resources.s);

            audio.Play();
            if (string.IsNullOrWhiteSpace(richTextBox1.Text))
            {
                MessageBox.Show(@"Введите домен!", @"Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                var array = File.ReadAllLines(Path);
                if (!richTextBox1.Text.Contains("."))
                {
                    MessageBox.Show(@"Домен должен быть вида сайт.зона", @"Внимание!");
                }
                else
                {
                    var t = 0;
                    if (array.Any(ar => ar.Equals(richTextBox1.Text)))
                    {
                        MessageBox.Show(@"Данный домен уже есть в фильтре", @"Внимание!");
                        t++;
                    }

                    if (t >= 1)
                    {
                        return;
                    }
                    using (var sw = new StreamWriter(Path, true))
                    {
                        sw.WriteLine("0.0.0.0 " + richTextBox1.Text);
                        Notification(@"Домен " + richTextBox1.Text + @" добавлен в черный список");
                    }

                    MainWindows.CmdExe(@"ipconfig / flushdns");
                }
            }
        }