ManagementBaseObject inPar = null;
ManagementBaseObject outPar = null;
ManagementClass mc = new
ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
try
{
foreach (ManagementObject mo in moc)
{
if (!(bool)mo["IPEnabled"])
continue;
inPar = mo.GetMethodParameters("EnableStatic");
inPar["IPAddress"] = new string[] {"10.57.245.184" };
inPar["SubnetMask"] = new string[] {"255.255.0.0" };
outPar = mo.InvokeMethod("EnableStatic", inPar,null);
//MonIP.Text = "10.59.245.186";
}
}
catch (Exception ex)
{
MessageBox.Show("Problème au changement d'IP (" +
ex.Message + ")", "erreur", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
Thanks
ReplyDeletesome references details plz
ReplyDeletethanks
ReplyDeleteHey It's not working
ReplyDelete