[问题] 设定网络组态

楼主: johnnywind (johnny)   2015-07-09 00:36:53
目前写个小程式来方便修改电脑的ipv4设定,
但遇到有些电脑可以有些电脑不行,
程式码主要如下,从手动改成自动取得
ManagementClass myClss =
new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection myMOC = myClss.GetInstances();
foreach (ManagementObject MOject in myMOC)
{
if (!(bool)MOject["IPEnabled"]) continue;
MOject.InvokeMethod("EnableDHCP", null);
MOject.InvokeMethod("SetDNSServerSearchOrder", null);
break;
}
有试过用try catch去找问题,但都没显示错误讯息,
请问有人有遇过这问题吗?

Links booklink

Contact Us: admin [ a t ] ucptt.com