C # obtain the local computer name, IP address, and MAC address

Source: Internet
Author: User

Using System;
Using System. Drawing;
Using System. Management;
Using System. Net;
Using System. Net. Sockets;
Using System. Collections;
Using System. ComponentModel;
Using System. Windows. Forms;
Using System. Data;

Namespace MAC_IP_name
{
/// <Summary>
/// Summary of Form1.
/// </Summary>
Public class Form1: System. Windows. Forms. Form
{
Private System. Windows. Forms. Label label4;
Private System. Windows. Forms. GroupBox groupBox1;
Private System. Windows. Forms. TextBox txtMac;
Private System. Windows. Forms. TextBox txtIp;
Private System. Windows. Forms. TextBox txtName;
Private System. Windows. Forms. Label lblMac;
Private System. Windows. Forms. Label lblIp;
Private System. Windows. Forms. Label lblName;
Private System. Windows. Forms. Button button1;
Private System. Windows. Forms. Button button2;
/// <Summary>
/// Required designer variables.
/// </Summary>
Private System. ComponentModel. Container components = null;

Public Form1 ()
{
//
// Required for Windows Form Designer support
//
InitializeComponent ();

//
// TODO: add Any constructor code after InitializeComponent calls
//
}

/// <Summary>
/// Clear all resources in use.
/// </Summary>
Protected override void Dispose (bool disposing)
{
If (disposing)
{
If (components! = Null)
{
Components. Dispose ();
}
}
Base. Dispose (disposing );
}

# Region code generated by Windows Form Designer
/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void InitializeComponent ()
{
This. label4 = new System. Windows. Forms. Label ();
This. groupBox1 = new System. Windows. Forms. GroupBox ();
This. button2 = new System. Windows. Forms. Button ();
This.txt Mac = new System. Windows. Forms. TextBox ();
This.txt Ip = new System. Windows. Forms. TextBox ();
This.txt Name = new System. Windows. Forms. TextBox ();
This. lblMac = new System. Windows. Forms. Label ();
This. lblIp = new System. Windows. Forms. Label ();
This. lblName = new System. Windows. Forms. Label ();
This. button1 = new System. Windows. Forms. Button ();
This. groupBox1.SuspendLayout ();
This. SuspendLayout ();
//
// Label4
//
This. label4.AutoSize = true;
This. label4.Font = new System. drawing. font (" _ GB2312", 15F, System. drawing. fontStyle. bold, System. drawing. graphicsUnit. point, (System. byte) (134 )));
This. label4.ForeColor = System. drawing. color. fromArgb (System. byte) (255), (System. byte) (128), (System. byte) (128 )));
This. label4.Location = new System. Drawing. Point (49, 16 );
This. label4.Name = "label4 ";
This. label4.Size = new System. Drawing. Size (245, 26 );
This. label4.TabIndex = 7;
This. label4.Text = "get the IP address and MAC address of the Local Computer ";
//
// GroupBox1
//
This. groupBox1.Controls. Add (this. button2 );
This.groupBox1.Controls.Add(this.txt Mac );
This.groupBox1.Controls.Add(this.txt Ip );
This.groupBox1.Controls.Add(this.txt Name );
& Nb

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.