/// <summary>
        /// Checks if PC is connected to a specified wireless LAN.
        /// </summary>
        /// <param name="ssid">SSID of wireless LAN</param>
        /// <returns>True if connected</returns>
        internal static bool IsWirelessNetworkConnected(string ssid)
        {
            if (string.IsNullOrWhiteSpace(ssid))
            {
                return(false);
            }

            if (NetworkInterface.GetAllNetworkInterfaces()
                .Where(x => x.OperationalStatus == OperationalStatus.Up)
                .All(x => x.NetworkInterfaceType != NetworkInterfaceType.Wireless80211))
            {
                return(false);
            }

            try
            {
                var ssids = NativeWifi.EnumerateConnectedNetworkSsids();

                return(ssids.Any(x => string.Equals(x, ssid, StringComparison.Ordinal)));
            }
            catch (Win32Exception)
            {
                return(false);
            }
        }
        public bool IsConnectedToWirelessNetwork()
        {
            NetworkIdentifier ss = NativeWifi.EnumerateConnectedNetworkSsids().FirstOrDefault();

            if (ss == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
 public string ConnectedSsid()
 {
     try
     {
         NetworkIdentifier ss     = NativeWifi.EnumerateConnectedNetworkSsids().FirstOrDefault();
         string            result = ss?.ToString();
         return(result);
     }
     catch (Exception)
     {
         return(null);
     }
 }
 public override bool CheckWifi()
 {
     connectionStateCallBack.StateChange("检查WIFI是否连接...");
     foreach (var ssid in NativeWifi.EnumerateConnectedNetworkSsids())
     {
         if (ssid.ToString().Equals("HXGNET"))
         {
             connectionStateCallBack.StateChange("已连接HXGNET...");
             return(true);
         }
     }
     connectionStateCallBack.StateChange("未连接HXGNET...");
     return(false);
 }
        private bool IsConnectedToPmcNetwork()
        {
            bool result = false;

            try
            {
                NetworkIdentifier ss = NativeWifi.EnumerateConnectedNetworkSsids().FirstOrDefault();
                if (ss != null)
                {
                    result = ss.ToString().Contains("PMC");
                }
            }
            catch (Exception ex)
            {
                EsEventManager.PublishEsEvent(EsEventSenderEnum.ComManager, "ERROR", EsMessagePriority.DebugInfo, "error in IsConnectedToPmcNetwork ", null, ex, null);
            }

            return(result);
        }
示例#6
0
        private static void ShowInformation()
        {
            Trace.WriteLine("===== Usable Interfaces =====");
            foreach (var interfaceInfo in NativeWifi.EnumerateInterfaces())
            {
                Trace.WriteLine($"Interface: {interfaceInfo.Description} ({interfaceInfo.Id})");
            }

            Trace.WriteLine("===== Usable Interface Connections =====");
            foreach (var interfaceInfo in NativeWifi.EnumerateInterfaceConnections())
            {
                Trace.WriteLine($"{{Interface: {interfaceInfo.Description} ({interfaceInfo.Id})");
                Trace.WriteLine($" Connection: {interfaceInfo.ConnectionMode}");
                Trace.WriteLine($" RadioOn: {interfaceInfo.IsRadioOn}");
                Trace.WriteLine($" Connected: {interfaceInfo.IsConnected}");
                Trace.WriteLine($" Profile: {interfaceInfo.ProfileName}}}");
            }

            Trace.WriteLine("===== Available Network SSIDs =====");
            foreach (var ssid in NativeWifi.EnumerateAvailableNetworkSsids())
            {
                Trace.WriteLine($"SSID: {ssid}");
            }

            Trace.WriteLine("===== Connected Network SSIDs =====");
            foreach (var ssid in NativeWifi.EnumerateConnectedNetworkSsids())
            {
                Trace.WriteLine($"SSID: {ssid}");
            }

            Trace.WriteLine("===== Available Networks =====");
            foreach (var network in NativeWifi.EnumerateAvailableNetworks())
            {
                Trace.WriteLine($"{{Interface: {network.Interface.Description} ({network.Interface.Id})");
                Trace.WriteLine($" SSID: {network.Ssid}");
                Trace.WriteLine($" BSS: {network.BssType}");
                Trace.WriteLine($" SignalQuality: {network.SignalQuality}");
                Trace.WriteLine($" Security: {network.IsSecurityEnabled}}}");
            }

            Trace.WriteLine("===== Available Network Groups =====");
            foreach (var network in NativeWifi.EnumerateAvailableNetworkGroups())
            {
                Trace.WriteLine($"{{Interface: {network.Interface.Description} ({network.Interface.Id})");
                Trace.WriteLine($" SSID: {network.Ssid}");
                Trace.WriteLine($" BssNetworks: {network.BssNetworks.Count}");
                Trace.WriteLine($" SignalQuality: {network.SignalQuality}");
                Trace.WriteLine($" LinkQuality: {network.LinkQuality}");
                Trace.WriteLine($" Band: {network.Band} GHz");
                Trace.WriteLine($" Channel: {network.Channel}}}");
            }

            Trace.WriteLine("===== BSS Networks =====");
            foreach (var network in NativeWifi.EnumerateBssNetworks())
            {
                Trace.WriteLine($"{{Interface: {network.Interface.Description} ({network.Interface.Id})");
                Trace.WriteLine($" SSID: {network.Ssid}");
                Trace.WriteLine($" BSS: {network.BssType}");
                Trace.WriteLine($" BSSID: {network.Bssid}");
                Trace.WriteLine($" SignalStrength: {network.SignalStrength}");
                Trace.WriteLine($" LinkQuality: {network.LinkQuality}");
                Trace.WriteLine($" Frequency: {network.Frequency} KHz");
                Trace.WriteLine($" Band: {network.Band} GHz");
                Trace.WriteLine($" Channel: {network.Channel}}}");
            }

            Trace.WriteLine("===== Network Profile Names =====");
            foreach (var name in NativeWifi.EnumerateProfileNames())
            {
                Trace.WriteLine($"Name: {name}");
            }

            Trace.WriteLine("===== Network Profiles =====");
            foreach (var profile in NativeWifi.EnumerateProfiles())
            {
                Trace.WriteLine($"{{Name: {profile.Name}");
                Trace.WriteLine($" Interface: {profile.Interface.Description} ({profile.Interface.Id})");
                Trace.WriteLine($" SSID: {profile.Document.Ssid}");
                Trace.WriteLine($" BSS: {profile.Document.BssType}");
                Trace.WriteLine($" Authentication: {profile.Document.Authentication}");
                Trace.WriteLine($" Encryption: {profile.Document.Encryption}");
                Trace.WriteLine($" AutoConnect: {profile.Document.IsAutoConnectEnabled}");
                Trace.WriteLine($" AutoSwitch: {profile.Document.IsAutoSwitchEnabled}");
                Trace.WriteLine($" Position: {profile.Position}}}");
            }

            Trace.WriteLine("===== Network Profile Radios =====");
            foreach (var profile in NativeWifi.EnumerateProfileRadios())
            {
                Trace.WriteLine($"{{Name: {profile.Name}");
                Trace.WriteLine($" Interface: {profile.Interface.Description} ({profile.Interface.Id})");
                Trace.WriteLine($" SSID: {profile.Document.Ssid}");
                Trace.WriteLine($" RadioOn: {profile.IsRadioOn}");
                Trace.WriteLine($" Connected: {profile.IsConnected}");
                Trace.WriteLine($" SignalQuality: {profile.SignalQuality}");
                Trace.WriteLine($" LinkQuality: {profile.LinkQuality}");
                Trace.WriteLine($" Band: {profile.Band} GHz");
                Trace.WriteLine($" Channel: {profile.Channel}}}");
            }
        }
示例#7
0
        private static void ShowInformation()
        {
            Trace.WriteLine("[Usable Interfaces]");
            foreach (var interfaceInfo in NativeWifi.EnumerateInterfaces())
            {
                Trace.WriteLine($"Interface: {interfaceInfo.Description} ({interfaceInfo.Id})");
            }

            Trace.WriteLine("[Available Network SSIDs]");
            foreach (var ssid in NativeWifi.EnumerateAvailableNetworkSsids())
            {
                Trace.WriteLine($"SSID: {ssid}");
            }

            Trace.WriteLine("[Connected Network SSIDs]");
            foreach (var ssid in NativeWifi.EnumerateConnectedNetworkSsids())
            {
                Trace.WriteLine($"SSID: {ssid}");
            }

            Trace.WriteLine("[Available Networks]");
            foreach (var network in NativeWifi.EnumerateAvailableNetworks())
            {
                Trace.WriteLine($"{{Interface: {network.Interface.Description} ({network.Interface.Id})");
                Trace.WriteLine($" SSID: {network.Ssid}");
                Trace.WriteLine($" BSS: {network.BssType}");
                Trace.WriteLine($" Signal: {network.SignalQuality}");
                Trace.WriteLine($" Security: {network.IsSecurityEnabled}}}");
            }

            Trace.WriteLine("[BSS Networks]");
            foreach (var network in NativeWifi.EnumerateBssNetworks())
            {
                Trace.WriteLine($"{{Interface: {network.Interface.Description} ({network.Interface.Id})");
                Trace.WriteLine($" SSID: {network.Ssid}");
                Trace.WriteLine($" BSS: {network.BssType}");
                Trace.WriteLine($" BSSID: {network.Bssid}");
                Trace.WriteLine($" Signal: {network.SignalStrength}");
                Trace.WriteLine($" Link: {network.LinkQuality}");
                Trace.WriteLine($" Frequency: {network.Frequency}");
                Trace.WriteLine($" Channel: {network.Channel}}}");
            }

            Trace.WriteLine("[Network Profile Names]");
            foreach (var name in NativeWifi.EnumerateProfileNames())
            {
                Trace.WriteLine($"Name: {name}");
            }

            Trace.WriteLine("[Network Profiles]");
            foreach (var profile in NativeWifi.EnumerateProfiles())
            {
                Trace.WriteLine($"{{Name: {profile.Name}");
                Trace.WriteLine($" Interface: {profile.Interface.Description} ({profile.Interface.Id})");
                Trace.WriteLine($" SSID: {profile.Ssid}");
                Trace.WriteLine($" BSS: {profile.BssType}");
                Trace.WriteLine($" Authentication: {profile.Authentication}");
                Trace.WriteLine($" Encryption: {profile.Encryption}");
                Trace.WriteLine($" Signal: {profile.SignalQuality}");
                Trace.WriteLine($" Position: {profile.Position}");
                Trace.WriteLine($" Automatic: {profile.IsAutomatic}");
                Trace.WriteLine($" Connected: {profile.IsConnected}}}");
            }
        }
示例#8
0
        private static void ShowInformation()
        {
            Trace.WriteLine("[Usable Interfaces]");
            foreach (var interfaceInfo in NativeWifi.EnumerateInterfaces())
            {
                Trace.WriteLine($"Interface: {interfaceInfo.Description} ({interfaceInfo.Id})");
            }

            Trace.WriteLine("");
            Trace.WriteLine("[Available Network SSIDs]");
            foreach (var ssid in NativeWifi.EnumerateAvailableNetworkSsids())
            {
                Trace.WriteLine($"SSID: {ssid}");
            }

            Trace.WriteLine("");
            Trace.WriteLine("[Connected Network SSIDs]");
            foreach (var ssid in NativeWifi.EnumerateConnectedNetworkSsids())
            {
                Trace.WriteLine($"SSID: {ssid}");
            }

            Trace.WriteLine("");
            Trace.WriteLine("[Available Networks]");
            foreach (var network in NativeWifi.EnumerateAvailableNetworks())
            {
                Trace.WriteLine($"{{Interface: {network.Interface.Description} ({network.Interface.Id})");
                Trace.WriteLine($" SSID: {network.Ssid}");
                Trace.WriteLine($" BSS: {network.BssType}");
                Trace.WriteLine($" Signal: {network.SignalQuality}");
                Trace.WriteLine($" Security: {network.IsSecurityEnabled}");
                Trace.WriteLine($" Auth Algorithm: {network.AuthAlgorithm.ToString()}");
                Trace.WriteLine($" Has Profile: {network.IsHasProfile} {(network.IsHasProfile ? "(" + network.ProfileName + ")" : network.ProfileName)}");

                Trace.WriteLine($" Cipher Algorithm: {network.CipherAlgorithm.ToString()}}}");
                var bssNetworks = NativeWifi.EnumerateBssNetworks(network);
                if (bssNetworks != null)
                {
                    Trace.WriteLine("[Child BSS Networks]");
                    foreach (var bssNetwork in bssNetworks)
                    {
                        Trace.WriteLine($"{{BSSID: {bssNetwork.Bssid}");
                        Trace.WriteLine($" SSID: {bssNetwork.Ssid}");
                        Trace.WriteLine($" BSS: {bssNetwork.BssType}");
                        Trace.WriteLine($" Signal: {bssNetwork.SignalStrength}");
                        Trace.WriteLine($" Link: {bssNetwork.LinkQuality}");
                        Trace.WriteLine($" Frequency: {bssNetwork.Frequency}");
                        Trace.WriteLine($" Channel: {bssNetwork.Channel}}}");
                    }
                }
            }

            Trace.WriteLine("");
            Trace.WriteLine("[BSS Networks]");
            foreach (var network in NativeWifi.EnumerateBssNetworks())
            {
                Trace.WriteLine($"{{Interface: {network.Interface.Description} ({network.Interface.Id})");
                Trace.WriteLine($" SSID: {network.Ssid}");
                Trace.WriteLine($" BSS: {network.BssType}");
                Trace.WriteLine($" BSSID: {network.Bssid}");
                Trace.WriteLine($" Signal: {network.SignalStrength}");
                Trace.WriteLine($" Link: {network.LinkQuality}");
                Trace.WriteLine($" Frequency: {network.Frequency}");
                Trace.WriteLine($" Channel: {network.Channel}}}");
            }

            Trace.WriteLine("");
            Trace.WriteLine("[Network Profile Names]");
            foreach (var name in NativeWifi.EnumerateProfileNames())
            {
                Trace.WriteLine($"Name: {name}");
            }

            Trace.WriteLine("");
            Trace.WriteLine("[Network Profiles]");
            foreach (var profile in NativeWifi.EnumerateProfiles())
            {
                Trace.WriteLine($"{{Name: {profile.Name}");
                Trace.WriteLine($" Interface: {profile.Interface.Description} ({profile.Interface.Id})");
                Trace.WriteLine($" SSID: {profile.Document.Ssid}");
                Trace.WriteLine($" BSS: {profile.Document.BssType}");
                Trace.WriteLine($" Authentication: {profile.Document.Authentication}");
                Trace.WriteLine($" Encryption: {profile.Document.Encryption}");
                Trace.WriteLine($" AutoConnect: {profile.Document.IsAutoConnectEnabled}");
                Trace.WriteLine($" AutoSwitch: {profile.Document.IsAutoSwitchEnabled}");
                Trace.WriteLine($" Position: {profile.Position}");
                Trace.WriteLine($" RadioOn: {profile.IsRadioOn}");
                Trace.WriteLine($" Signal: {profile.SignalQuality}");
                Trace.WriteLine($" Connected: {profile.IsConnected}}}");
            }
        }