这是一个很好的源码给大家一起分享一下
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);
}
}
}
}