是WindowsForm程序
从网上找了一下那方法过时了,用不了
给个例子吧(有无答案都会给分)

解决方案 »

  1.   

    本地计算机名
    SystemInformation.ComputerName
      

  2.   


    private void button1_Click(object sender, System.EventArgs e)
    {//获取系统信息
    try
    {
    this.label1.Text="用户名:"+SystemInformation.UserName;
    this.label2.Text="计算机名:"+SystemInformation.ComputerName;
    this.label3.Text="操作系统:"+Environment.OSVersion.Platform;
    this.label4.Text="版本号:"+Environment.OSVersion.Version;
        if(SystemInformation.BootMode.ToString()=="Normal")
    this.label5.Text="启动方式:正常启动";
    if(SystemInformation.BootMode.ToString()=="FailSafe")
    this.label5.Text="启动方式:安全启动";
    if(SystemInformation.BootMode.ToString()=="FailSafeWithNetwork")
    this.label5.Text="启动方式:通过网络服务启动";
    if(SystemInformation.Network==true)
                        this.label6.Text="网络连接:已连接";
    else
    this.label6.Text="网络连接:未连接";
    this.label7.Text="显示器数量:"+SystemInformation.MonitorCount.ToString();
                    this.label8.Text="显示器分辨率:"+SystemInformation.PrimaryMonitorMaximizedWindowSize.Width.ToString()+"X"+
    SystemInformation.PrimaryMonitorMaximizedWindowSize.Height.ToString();
    }
    catch(Exception Err)
    {
    MessageBox.Show("获取系统信息发生错误!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
    }
    }
      

  3.   


    方法一:使用逐个IP地址扫描的方式
    利用多线程来对每个IP逐个扫描。
    ComputerAddressInfo cai = new ComputerAddressInfo("192.168.1",42,53); 
    Thread thScan = new Thread(new ThreadStart(cai.ScanComputers)); 
    thScan.Start(); 
    //... 
        public class ComputerAddressInfo 
        { 
            private int startIP = 0; 
            private int endIP = 0; 
            private string ipPrefix = ""; 
            private ArrayList computerList = null;        public ComputerAddressInfo(string ipPrefix,int startIP,int endIP) 
            { 
                this.startIP = startIP; 
                this.endIP = endIP; 
                this.ipPrefix = ipPrefix; 
                computerList = new ArrayList(); 
            } 
      
            public void ScanComputers() 
            { 
                for(int i=startIP;i<=endIP;i++) 
                { 
                    string scanIP = ipPrefix +"."+i.ToString(); 
                    IPAddress myScanIP = IPAddress.Parse(scanIP); 
                    IPHostEntry myScanHost = null; 
                    string[] arr = new string[2]; 
                    try 
                    { 
                        myScanHost = Dns.GetHostByAddress(myScanIP); 
                    } 
                    catch 
                    { 
                        continue; 
                    } 
                    if (myScanHost != null) 
                    { 
                        arr[0] = myScanHost.HostName; 
                        arr[1] = scanIP; 
                        computerList.Add(arr); 
                    } 
                } 
            } 
        } 方法二:使用Active Directory 
            public static ArrayList GetComputerList()  
            {  
                ArrayList list = new ArrayList(); 
                //or  use  "WinNT://your_domain_name"  
                DirectoryEntry  root  =  new  DirectoryEntry("WinNT:"); 
                DirectoryEntries  domains  =  root.Children;  
                domains.SchemaFilter.Add("domain");  
                foreach  (DirectoryEntry  domain  in  domains)  
                {    
                    DirectoryEntries  computers  =  domain.Children;  
                    computers.SchemaFilter.Add("computer");  
                    foreach  (DirectoryEntry  computer  in  computers)  
                    {  
                        object[] arr = new string[3]; 
                        IPHostEntry  iphe = null; 
                        try 
                        { 
                            iphe  =  Dns.GetHostByName(computer.Name); 
                        } 
                        catch 
                        {
                            continue; 
                        } 
                        arr[0] = domain.Name; 
                        arr[1] = computer.Name; 
                        if ( iphe != null && iphe.AddressList.Length >0 ) 
                        {
                            for ( int i=0;i 
                                arr[2] += iphe.AddressList[i].ToString()+","; 
                            arr[2] = arr[2].ToString().Remove(arr[2].ToString().Length-1,1); 
                        } 
                        else 
                            arr[2] = ""; 
                        list.Add(arr); 
                    }  
                }  
                return list; 
            }  
    网上找的..参考下吧