The next code uses the Managed Wifi API, The library uses the Native Wifi API, available since Windows Vista and Windows XP SP2 (in a limited fashion, and only after applying a hotfix provided in KB article 918997). Older versions of Windows are not supported.
namespace DelphiPrismWifidetection; //Author : Rodrigo Ruz. 2009-09-29 //Shine Your crazy Diamond. interface uses NativeWifi,//You must add the reference to the library ManagedWifi.dll System.Text; type ConsoleApp = class private class method GetStringForSSID(ssid : Wlan.Dot11Ssid ) : string; class method GetStringFornumberOfBssids (numberOfBssids : Int32 ) : string; public class method Main; end; implementation class method ConsoleApp.GetStringForSSID(ssid : Wlan.Dot11Ssid ) : string; begin Result:= Encoding.ASCII.GetString( ssid.SSID, 0, Int32( ssid.SSIDLength) ); end; class method ConsoleApp.GetStringFornumberOfBssids (numberOfBssids : Int32 ) : string; begin case numberOfBssids of 1: Result:='infrastructure'; 2: Result:='independent'; 3: Result:='any'; else Result:='Unknow'; end; // case end; class method ConsoleApp.Main; begin var client : WlanClient := new WlanClient(); for each wlanIface in client.Interfaces do begin var networks : Array of Wlan.WlanAvailableNetwork := wlanIface.GetAvailableNetworkList(NativeWifi.Wlan.WlanGetAvailableNetworkFlags.IncludeAllAdhocProfiles); for each network in networks do begin // for more info goto http://msdn.microsoft.com/en-us/library/ms707403%28VS.85%29.aspx Console.WriteLine( "┌---------------------------------------------------------------¬"); Console.WriteLine( "|Network Detected {0,-40} |", GetStringForSSID(network.dot11Ssid)); Console.WriteLine( "├---------------------------------------------------------------┤"); Console.WriteLine( "| CipherAlgorithm {0,-40} |", network.dot11DefaultCipherAlgorithm.ToString()); Console.WriteLine( "| DefaultAuthAlgorithm {0,-40} |", network.dot11DefaultAuthAlgorithm.ToString()); Console.WriteLine( "| dot11Ssid {0,-40} |", network.dot11Ssid.ToString()); Console.WriteLine( "| networkConnectable {0,-40} |", network.networkConnectable.ToString()); if not network.networkConnectable then Console.WriteLine( "| NotConnectableReason {0,-40} |", network.wlanNotConnectableReason.ToString()); Console.WriteLine( "| morePhyTypes {0,-40} |", network.morePhyTypes.ToString()); Console.WriteLine( "| (BSS) network type {0,-40} |", GetStringFornumberOfBssids(network.numberOfBssids)); Console.WriteLine( "| profileName {0,-40} |", network.profileName.ToString()); Console.WriteLine( "| securityEnabled {0,-40} |", network.securityEnabled.ToString()); Console.WriteLine( "| wlanSignalQuality {0,-40} |", network.wlanSignalQuality.ToString()); Console.WriteLine( "└---------------------------------------------------------------┘"); end; end; Console.ReadLine(); end; end.
and the result is
Update
Download the full source code from here
Bye.