473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

WMI Wifi discovery

How do I discover the networks detected by my Wi-Fi adapter?
I tried to use WMI. It shows information of the connected network
only.
There are some other WiFi access points available. But I am not able
to retrieve them using WMI(using c# code). The code which I tried is
given below.

Please let me know if we can detect other access points, which is
available and not currently connected with my adapter.

ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\WMI",
"SELECT * FROM
MSNdis_80211_ServiceSetIdentifier");

foreach (ManagementObject queryObj in searcher.Get())
{

Console.WriteLine("-----------------------------------");

Console.WriteLine("MSNdis_80211_ServiceSetIdentifi er instance");

Console.WriteLine("-----------------------------------");

if(queryObj["Ndis80211SsId"] == null)
Console.WriteLine("Ndis80211SsId: {0}",
queryObj["Ndis80211SsId"]);
else
{
Byte[] arrNdis80211SsId = (Byte[])
(queryObj["Ndis80211SsId"]);
foreach (Byte arrValue in arrNdis80211SsId)
{
Console.WriteLine("Ndis80211SsId: {0}",
arrValue);
}
}
}

Thanks
Srinivasan

Jun 5 '07 #1
1 16830
using System;
using System.Collections.Generic;
using System.Management;
using System.Text;

namespace The_Wifi_Project
{
class Program
{
const string wql_listar_adaptadores_conectados = "SELECT * FROM
MSNdis_80211_BaseServiceSetIdentifier WHERE Active = True";
const string wql_listar_redes_inalámbricas = "SELECT * FROM
MSNDis_80211_BSSIList";
private static void WIFI_list()
{
/* Establecer una conexión con el entorno de administración */
ManagementScope managementScope = new
ManagementScope("\\\\.\\root\\wmi");

System.Management.ObjectQuery objectQuery = new
System.Management.ObjectQuery(wql_listar_redes_ina lámbricas);
ManagementObjectSearcher managementObjectSearcher = new
ManagementObjectSearcher(managementScope, objectQuery);
ManagementObjectCollection moc = managementObjectSearcher.Get();
ManagementObjectCollection.ManagementObjectEnumera tor moe =
moc.GetEnumerator();
moe.MoveNext();
ManagementBaseObject[] objarr =
(ManagementBaseObject[])moe.Current.Properties["Ndis80211BSSIList"].Value;

if (objarr != null)
{
foreach (ManagementBaseObject obj in objarr)
{
char[] ssid =
Encoding.ASCII.GetChars((byte[])obj["Ndis80211Ssid"]);
Console.Write("SSID: ");
int i;
for (i = 0; i < 32 && ssid[i] != '\0'; i++)
{
Console.Write(ssid[i]);
}
uint rs = (uint)obj["Ndis80211Rssi"];
Console.Write(".");
Console.WriteLine(" RSSI: " + rs);
}
}
}

static void Main(string[] args)
{
Console.Clear();

foreach (string argumento in args)
{
String argument = argumento.ToLower();
if (argument.Equals("list"))
{
WIFI_list();
break;
}
else
{
Console.WriteLine("Error: acción no reconocida");
}
}
}
}
}
"Srini" wrote:
How do I discover the networks detected by my Wi-Fi adapter?
I tried to use WMI. It shows information of the connected network
only.
There are some other WiFi access points available. But I am not able
to retrieve them using WMI(using c# code). The code which I tried is
given below.

Please let me know if we can detect other access points, which is
available and not currently connected with my adapter.

ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\WMI",
"SELECT * FROM
MSNdis_80211_ServiceSetIdentifier");

foreach (ManagementObject queryObj in searcher.Get())
{

Console.WriteLine("-----------------------------------");

Console.WriteLine("MSNdis_80211_ServiceSetIdentifi er instance");

Console.WriteLine("-----------------------------------");

if(queryObj["Ndis80211SsId"] == null)
Console.WriteLine("Ndis80211SsId: {0}",
queryObj["Ndis80211SsId"]);
else
{
Byte[] arrNdis80211SsId = (Byte[])
(queryObj["Ndis80211SsId"]);
foreach (Byte arrValue in arrNdis80211SsId)
{
Console.WriteLine("Ndis80211SsId: {0}",
arrValue);
}
}
}

Thanks
Srinivasan

Jul 12 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Anurag | last post by:
Hi, I understand that the dbm cfg parameter "DISCOVER" controls whether Search or Known discovery is applicable. Additionally, Search discovery provides a superset of Known discovery. I completely...
3
by: Jon Vaughan | last post by:
Hello all, I have written a program that is a client / server program running over a wifi network. When the computer boots windows connects to the network 99% of the time , but now and again it...
0
by: Maroller | last post by:
I have a WiFi network comprising a Netgear router, a desktop and a laptop. An ASP web service is set up on the desktop IIS. But when I try to add a web reference to an ASP web application developed...
4
by: Tarun | last post by:
Hi all, How can I write a VB.NET function that returns detectable WiFi networks? That is, how can I obtain a list of available network SSID's, MAC Address and IP Address of WIFI hotspots within...
7
by: Chris Mullins | last post by:
I'm in the process of building a number of (Web) Services using .NET 3.0 and WCF. These services are intended to be deployed within the Intranet of a very, very large orginization. I need to...
4
by: BLUE | last post by:
Psion WorkAbout Pro with Windows CE .NET 4.2 Dealer gave me PowerAPIOn.exe and PowerAPIOff.exe to turn on/off tag reader, but I want to do it programmatically and do the same with WiFi and...
0
by: Alistair George | last post by:
Hello all. I have been trying to find an api that works with external (not card) devices so that the application works with all types of product, eg all-in-one wifi/adsl/router such as Dlink...
4
Elias Alhanatis
by: Elias Alhanatis | last post by:
Hello! I run Ubuntu from a live disk distribution , and although my wifi card is active and it detects the wifi network of my house , when i enter the WEP Hex Key , it refuses to connect , with no...
9
by: George Berger | last post by:
Have an iPhone 4, want to use Fring (app) to make video calls over wifi. Unable to get it to load up over wifi on my home network. Using a belkin wireless G router. My parents have the same router...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.