/// <summary> /// Cambia la IP del sistema operativo al estádo dinámico /// Si ocurre un error se arroja la excepción /// </summary> internal static bool resetAdapter(NetData netData) { Radios radios = Radios.GetRadios(); foreach (IRadio radio in radios) { if (radio.RadioType.Equals(RadioType.WiFi)) { WiFiRadio wifiRadio = (WiFiRadio)radio; wifiRadio.RadioState = RadioState.Off; wifiRadio.RadioState = RadioState.On; } } INetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); foreach (INetworkInterface networkInterface in networkInterfaces) { if (netData.NetworkAdapter.Name.Equals(networkInterface.Name)) { networkInterface.Rebind(); return(true); } } return(false); }
/// <summary> /// Cambia la IP del sistema operativo al estádo dinámico /// Si ocurre un error se arroja la excepción /// </summary> internal static void turnOffAdapter(NetData netData) { Radios radios = Radios.GetRadios(); foreach (IRadio radio in radios) { if (radio.RadioType.Equals(RadioType.WiFi)) { WiFiRadio wifiRadio = (WiFiRadio)radio; wifiRadio.RadioState = RadioState.Off; } } }
/// <summary> /// Busca el adaptador de red WIFI /// </summary> /// <returns>El adaptador de red Wifi</returns> public static NetworkAdapter getWifiAdapter() { try { Radios radios = Radios.GetRadios(); foreach (IRadio radio in radios) { if (radio.RadioType.Equals(RadioType.WiFi)) { WiFiRadio wifiRadio = (WiFiRadio)radio; NetworkAdapter adapter = new NetworkAdapter(); adapter.Name = wifiRadio.DeviceName; adapter.Name = adapter.Name.Substring(adapter.Name.IndexOf("\\") + 1); adapter.Description = wifiRadio.DisplayName; INetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); foreach (INetworkInterface networkInterface in networkInterfaces) { try { WirelessZeroConfigNetworkInterface Wadapter = (WirelessZeroConfigNetworkInterface)networkInterface; adapter.Name = Wadapter.Name; adapter.Description = Wadapter.Description; break; } catch (Exception) { adapter.Description += "interface NOT FOUND"; } } return(adapter); } } return(null); } catch (ThreadAbortException e) { throw e; } catch (Exception e) { throw e; } }
/// <summary> /// Cambia la IP del sistema operativo al estádo dinámico /// Si ocurre un error se arroja la excepción /// </summary> internal static void turnOnAdapter(NetData netData, Boolean forced) { Radios radios = Radios.GetRadios(); foreach (IRadio radio in radios) { if (radio.RadioType.Equals(RadioType.WiFi)) { WiFiRadio wifiRadio = (WiFiRadio)radio; if (forced) { wifiRadio.RadioState = RadioState.On; } else if (wifiRadio.RadioState == RadioState.Off) { wifiRadio.RadioState = RadioState.On; } } } }