private void Init() { try { WlanUtils.Throw_On_Win32_Error(wlanapi.WlanOpenHandle(wlanapi.WLAN_CLIENT_VERSION_VISTA, IntPtr.Zero, out this._ServerVersion, ref this._WlanHandle)); WLAN_NOTIFICATION_SOURCE notifSource; WlanUtils.Throw_On_Win32_Error(wlanapi.WlanRegisterNotification(this._WlanHandle, WLAN_NOTIFICATION_SOURCE.All, true, this._notificationCallback, IntPtr.Zero, IntPtr.Zero, out notifSource)); WLAN_HOSTED_NETWORK_REASON failReason = this.InitSettings(); if (failReason != WLAN_HOSTED_NETWORK_REASON.wlan_hosted_network_reason_success) { throw new Exception("Init Error WlanHostedNetworkInitSettings: " + failReason.ToString()); } //我加的 var netStat = QueryStatus(); _HostedNetworkState = netStat.HostedNetworkState; foreach (var i in netStat.PeerList) { WlanStation station = new WlanStation(i); _Stations[station.MacAddress] = station; } } catch { wlanapi.WlanCloseHandle(this._WlanHandle, IntPtr.Zero); throw; } }
protected void onStationJoin(WLAN_HOSTED_NETWORK_PEER_STATE stationState) { var pStation = new WlanStation(stationState); this._Stations[pStation.MacAddress] = pStation; if (this.StationJoin != null) { this.StationJoin(this, EventArgs.Empty); } }
public ConnectedPeer(WlanStation peer) : this() { this.MacAddress = peer.MacAddress; }