コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Process netUtility = new Process();

            netUtility.StartInfo.FileName = "net.exe";

            netUtility.StartInfo.CreateNoWindow = true;

            netUtility.StartInfo.Arguments = "view";

            netUtility.StartInfo.RedirectStandardOutput = true;

            netUtility.StartInfo.UseShellExecute = false;

            netUtility.StartInfo.RedirectStandardError = true;

            netUtility.Start();

            StreamReader streamReader = new StreamReader(netUtility.StandardOutput.BaseStream, netUtility.StandardOutput.CurrentEncoding);

            string line = "";

            while ((line = streamReader.ReadLine()) != null)
            {
                if (line.StartsWith("\\"))
                {
                    listView1.Items.Add(line.Substring(2).Substring(0, line.Substring(2).IndexOf(" ")).ToUpper());
                    // IPAddress[] allipaddlist = Dns.GetHostAddresses(Dns.GetHostName());
                    //IPHostEntry he = new IPHostEntry();
                }
            }
            IPHostEntry h; int j = 0;

            try
            {
                for (j = 0; j < listView1.Items.Count; j++)
                {
                    try
                    {
                        string hostname = listView1.Items[j].Text;
                        h = Dns.GetHostByName(hostname);
                        for (int i = 0; i < h.AddressList.Length; i++)
                        {
                            listView1.Items[j].SubItems.Add(h.AddressList[i].ToString());
                        }
                        if (h.AddressList.Length == 1)
                        {
                            listView1.Items[j].SubItems.Add("No Another IP");
                        }
                        listView1.Items[j].SubItems.Add(GetMacUsingARP(h.AddressList[0].ToString()));

                        Ping        obj_ping = new Ping();
                        PingOptions obj_opt  = new PingOptions();
                        PingReply   obj_reply;
                        obj_reply = obj_ping.Send(h.AddressList[0].ToString());
                        if (obj_reply.Status == IPStatus.Success)
                        {
                            listView1.Items[j].SubItems.Add("Active");
                            listView1.Items[j].SubItems.Add("Checking..");

                            listView1.Items[j].SubItems.Add(obj_reply.Buffer.Length.ToString());
                            listView1.Items[j].SubItems.Add(obj_reply.Options.Ttl.ToString());
                        }
                    }
                    catch { }
                }
            }
            catch
            {
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Rbravo3443/Music-Streamer
        private void Form1_Load(object sender, EventArgs e)
        {
            //Setting values into initialized variables
            myPing             = new Ping();
            buffer1            = new byte[32];
            timeout            = 1000;
            pingOptions        = new PingOptions();
            mp.URL             = "";
            media              = mp.mediaCollection;
            mp.settings.volume = VolumeSlider.Value * 7;
            request1           = WebRequest.Create("http://193.200.42.211:80/pulstranceHD.mp3");
            request2           = WebRequest.Create("http://163.172.169.217:80/asp-s");
            request3           = WebRequest.Create("http://185.40.31.39:7999/1/;.m3u");
            timer              = new Timer();
            timer.Interval     = (3 * 1000);
            timer.Tick        += new EventHandler(timer_tick);
            timer2             = new Timer();
            timer2.Interval    = (3 * 1000);
            timer2.Tick       += new EventHandler(timer2_tick);
            this.MaximizeBox   = false;


            radioButton1.Enabled = false;
            radioButton2.Enabled = false;
            radioButton3.Enabled = false;
            //Checking if there is an established connection to the internet
            try
            {
                reply = myPing.Send(host, timeout, buffer1, pingOptions);
            }
            catch
            {
                errorState = 1;
                timer2.Start();
            }

            //try
            //{
            //response1 = (HttpWebResponse)request1.GetResponse();
            //response2 = (HttpWebResponse)request2.GetResponse();
            //response3 = (HttpWebResponse)request3.GetResponse();

            //}catch
            //{
            //  MessageBox.Show("You are currently disconnected from the internet! Music streaming services will not be available without a connection!", "Notice");
            //errorState = 1;
            //}


            if (errorState != 1)
            {
                timer.Start();
            }

            //Checking if the streams are currently online, if not disable the connection and the assigned button
            //  if (response1 == null || response1.StatusCode != HttpStatusCode.OK)
            //{
            // MessageBox.Show("Note: Trance stream is currently down!","Notice");

            //}


            //Load Saved Favorite Songs
            list = Properties.Settings.Default.Songs;
            if (list != null)
            {
                foreach (String list2 in list)
                {
                    FavBox.Items.Add(list2);
                }
            }
        }