public static int QueryAdapter(string adapterName, out INTF_ENTRY entry) { // Attempt to get the status of the indicated // interface by calling WZCQueryInterface. If // it works, we return true; if not, false. // Note that the first parameter, the WZC server, // is set to null, apparently indicating that the // local machine is the target. entry = new INTF_ENTRY(); INTF_FLAGS flags = 0; entry.Guid = adapterName; int retVal = 0; try { retVal = WZC.WZCQueryInterface(null, INTF_FLAGS.INTF_ALL, ref entry, out flags); } catch (Exception ex) { // on a throw, the return value needs to get set to a non-zero try { WZC.WZCDeleteIntfObj(ref entry); } catch { } return(-1); } return(retVal); }
internal static List <IAccessPoint> GetAPs(string adapterName) { var apList = new List <IAccessPoint>(); INTF_ENTRY entry = new INTF_ENTRY(); entry.Guid = adapterName; INTF_FLAGS flags = 0; int result = WZCQueryInterface(null, INTF_FLAGS.INTF_ALL, ref entry, out flags); if (result != 0) { entry.Dispose(); throw new Exception("WZCQueryInterface failed for " + adapterName); } try { // Figure out how many SSIDs there are. if (entry.rdBSSIDList.cbData == 0) { // list is empty return(apList); } NDIS_802_11_BSSID_LIST rawlist = new NDIS_802_11_BSSID_LIST(entry.rdBSSIDList.lpData, true); for (int i = 0; i < rawlist.NumberOfItems; i++) { // Get the next raw item from the list. BSSID bssid = rawlist.Item(i); // Using the raw item, create a cooked // SSID item. AccessPoint ssid = new AccessPoint(bssid); // Add the new item to this. apList.Add(ssid); } return(apList); } finally { WZCDeleteIntfObj(ref entry); } }
public static void ResetAdapter(string adapterName) { INTF_ENTRY_EX intf = new INTF_ENTRY_EX(); intf.Guid = adapterName; INTF_FLAGS flags = 0; try { WZCSetInterfaceEx(null, INTF_FLAGS.INTF_PREFLIST, ref intf, out flags); } catch (MissingMethodException) { throw new PlatformNotSupportedException("The required OS components for this method are not present."); } }
public static int SetAdapter(INTF_ENTRY entry, INTF_FLAGS flags) { return(WZC.WZCSetInterface(null, flags, ref entry, null)); }
WZCSetInterfaceEx( string pSrvAddr, INTF_FLAGS dwInFlags, ref INTF_ENTRY_EX pIntf, out INTF_FLAGS pdwOutFlags);
WZCSetInterface( string pSrvAddr, INTF_FLAGS dwInFlags, ref INTF_ENTRY pIntf, object pdwOutFlags);
WZCQueryInterface( string pSrvAddr, INTF_FLAGS dwInFlags, ref INTF_ENTRY pIntf, out INTF_FLAGS pdwOutFlags);