To xinyulou(心雨楼):
什么办法呢?

解决方案 »

  1.   

    如何获取局域网内所有机器名
    http://expert.csdn.net/Expert/topic/1887/1887810.xml?temp=4.668826E-02
      

  2.   

    private CurrencyManager sourceCM;
    private DataView sourceView;
    this.OnlyOneAdapter.strSQL=string.Format("select ID,ShiJian,CaoZuoRen,ZhongLei,ShuLiang,QiHao,ZiHao,FangFa,ND,convert(bit,0) as DF,datareturn from T_DangAn_JiLu where LeiBie='{0}' and Flag=0 and ND='{1}' and CaoZuoRen='{2}'","文件",this.ND,this.CaoZuoRen);
    this.OnlyOneAdapter.GiveMeData(out ds);
    dataGrid1.SetDataBinding(ds,"Table");
    sourceCM = (CurrencyManager)this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember];
    sourceView=((DataView)sourceCM.List);
    sourceView.AllowNew=false;
    sourceView.AllowDelete=false; private void getnetcomputername() //取局域网内的全部计算机
    {
    //or  use  "WinNT://your_domain_name"  
    DirectoryEntry  root  =  new  DirectoryEntry("WinNT:");  
    DirectoryEntries  domains  =  root.Children;  
    domains.SchemaFilter.Add("domain");  
    foreach  (DirectoryEntry  domain  in  domains)  
    {  
    string ss=domain.Name.ToString();
    // if(domain.Name.ToString()==domain_name) 
    // {
    DirectoryEntries  computers  =  domain.Children;  
    computers.SchemaFilter.Add("computer");  
    foreach  (DirectoryEntry  computer  in  computers)  
    {  
    try
    {
    IPHostEntry  iphe  =  Dns.GetHostByName(computer.Name); 

    foreach  (IPAddress  ip  in  iphe.AddressList)  
    {  
    this.LB.Items.Add(computer.Name);    
    }  
    DirectoryEntries  users  =  computer.Children;  
    }
    catch(Exception){}

    // }
    }  
    }