Exemplo n.º 1
0
        private static bool DeleteAllLoopAdapters()
        {
            NetworkAdapterInstaller.SendMessage("开始删除虚拟网卡");
            List <ManagementBaseObject> managementBaseObjects = NetworkAdapterInstaller.QuerySysinfo("Win32_NetworkAdapter", "Caption like '%Loopback Adapter%'");

            if (managementBaseObjects.Count <= 0)
            {
                NetworkAdapterInstaller.SendErrorMessage("没有可删除的虚拟网卡");
                return(true);
            }
            foreach (ManagementBaseObject managementBaseObject in managementBaseObjects)
            {
                NetworkAdapterInstaller.SendMessage(string.Format("找到虚拟网卡{0}", managementBaseObject["Name"]));
                NetworkAdapterInstaller.RunCmd(string.Format("devcon.exe /r remove @{0}", managementBaseObject["PNPDeviceID"]), new Action <Process>(NetworkAdapterInstaller.DEBUGWriteToConsole));
            }
            if (NetworkAdapterInstaller.QuerySysinfo("Win32_NetworkAdapter", "Caption like '%Loopback Adapter%'").Count == 0)
            {
                NetworkAdapterInstaller.SendMessage("删除成功!");
                return(false);
            }
            NetworkAdapterInstaller.SendMessage("删除失败!");
            return(false);
        }
Exemplo n.º 2
0
 private static List <ManagementBaseObject> QueryInstalledLoopbackAdapters()
 {
     return(NetworkAdapterInstaller.QuerySysinfo("Win32_NetworkAdapter", "Caption like '%Loopback Adapter%'"));
 }