熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

C#實現更改IP功能源代碼

2013-11-13 10:21:32  來源: .NET編程 

  這是一個很好的源碼給大家一起分享一下

 moInvokeMethod(EnableStatic iObj null);

  iObj = moGetMethodParameters(SetGateways);
            iObj[DefaultIPGateway] = gateways;
            iObj[GatewayCostMetric] = gatewayCostMetric;
            oObj = moInvokeMethod(SetGateways iObj null);

  iObj = moGetMethodParameters(SetDNSServerSearchOrder);
            iObj[DNSServerSearchOrder] = dnsServer;
            oObj = moInvokeMethod(SetDNSServerSearchOrder iObj null);
        }
    }

  ///<summary>DHCPEnabled</summary>
    public void EnableDHCP()
    {
        foreach (ManagementObject mo in moc)
        {
            if (!(bool)mo[IPEnabled]) continue;

  if (!(bool)mo[DHCPEnabled])
            {
                iObj = moGetMethodParameters(EnableDHCP);
                oObj = moInvokeMethod(EnableDHCP iObj null);
            }
        }
    }
}


From:http://tw.wingwit.com/Article/program/net/201311/13369.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.