public void useWZCDeleteIntfObj(ref INTF_ENTRY Intf) //you may wish to use a better method name //you may wish to put some guards here, to check that Intf is valid before passing it to the native library. { try{ WZCDeleteIntfObj(Intf); }catch (ExternalException e) { //try to catch more specific exception types, such as SEHException. //handle the exception } }
public void useWZCDeleteIntfObj(ref INTF_ENTRY Intf) { //you may wish to put some guards here, to check that Intf is valid before passing it to the native library. try{ WZCDeleteIntfObj(Intf); }catch (Exception e) { //you want to catch more specific exception types. Catching Exception is not ideal, and is used for this example only //handle the exception } }
internal unsafe void RefreshListPreferred(bool nearbyOnly) { // If the caller wants only the local preferred APs, // we check nearby list and, if the AP is not there, // we don't add it to our own preferred list. AccessPointCollection apc = null; if (nearbyOnly) { apc = adapter.NearbyAccessPoints; } // First step is to get the INTF_ENTRY for the adapter. // This includes the list of preferred SSID values. INTF_ENTRY ie = INTF_ENTRY.GetEntry(this.adapter.Name); // The field rdStSSIDList is the preferred list. It comes // in the form of a WZC_802_11_CONFIG_LIST. RAW_DATA rd = ie.rdStSSIDList; WZC_WLAN_CONFIG_LIST cl = new WZC_WLAN_CONFIG_LIST(rd); // Step through the list and add a new AP to the // collection for each entry. for (int i = 0; i < cl.NumberOfItems; i++) { WZC_WLAN_CONFIG c = cl.Item(0); // Get a NDIS_WLAN_BSSID corresponding to the // part of the WZC_WLAN_CONFIG entry and use that // to build an AccessPoint instance for this // entry. NDIS_WLAN_BSSID bssid = c.ToBssid(); // If we're only showing those which we can hear, // see if the current SSID is in the nearby list. if (nearbyOnly) { // Find the currently active AP with the SSID // to match the one we're working on. AccessPoint activeAP = apc.FindBySSID(bssid.SSID); int ss; // If the given SSID is not in range, don't add // an entry to the list. if (activeAP != null) { // Update signal strength. ss = activeAP.SignalStrengthInDecibels; // Copy the signal strength value to the // NDIS_WLAN_BSSID structure for the // preferred list entry. bssid.Rssi = ss; // Create the AP instance and add it to the // preferred list. AccessPoint ap = new AccessPoint(bssid); this.List.Add(ap); } } else { // Create the AP instance and add it to the // preferred list. The signal strength will // not necessarily be valid. AccessPoint ap = new AccessPoint(bssid); this.List.Add(ap); } } }
private static extern void WZCDeleteIntfObj(ref INTF_ENTRY Intf);