How to detect a machine in the local area network has been connected

zhaozj2021-02-16  55

Private void scantarget () {// Constructs 31-8bit bits of the IP address, that is, the front section of the fixed IP address // numericupdown1 is the defined system.windows.Forms.NumericUpdown control string stripaddress = "192.168.1."; / / Start Scanning Address INT NSTRAT = 0; // Terminate Scan Address INT NEND = 255; // Scanning Operation for (INT I = NSTRAT; I <= NEND; I ) {String StrscanipAdd = StripAddress i.toString (); // Convert to IP Address MyScanip = ipaddress.parse (STRSCANIPADD); try {// You can join your own, enhanced function // DNS.GETHOSTBYADDRESS method: DNS host information is obtained according to IP // Address. IPHostEntry myScanHost = Dns.GetHostByAddress (myScanIP); // get the host name string strHostName = myScanHost.HostName.ToString (); richTextBox1.AppendText (strScanIPAdd "->" strHostName "/ r");} catch (Exception error) {MessageBox.show (Error.Message);}} // for} // privat

转载请注明原文地址:https://www.9cbs.com/read-18076.html

New Post(0)