473,387 Members | 1,493 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,387 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 16825
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.