473,657 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.

ManagementObjec tSearcher searcher =
new ManagementObjec tSearcher("root \\WMI",
"SELECT * FROM
MSNdis_80211_Se rviceSetIdentif ier");

foreach (ManagementObje ct queryObj in searcher.Get())
{

Console.WriteLi ne("-----------------------------------");

Console.WriteLi ne("MSNdis_8021 1_ServiceSetIde ntifier instance");

Console.WriteLi ne("-----------------------------------");

if(queryObj["Ndis80211S sId"] == null)
Console.WriteLi ne("Ndis80211Ss Id: {0}",
queryObj["Ndis80211S sId"]);
else
{
Byte[] arrNdis80211SsI d = (Byte[])
(queryObj["Ndis80211S sId"]);
foreach (Byte arrValue in arrNdis80211SsI d)
{
Console.WriteLi ne("Ndis80211Ss Id: {0}",
arrValue);
}
}
}

Thanks
Srinivasan

Jun 5 '07 #1
1 16887
using System;
using System.Collecti ons.Generic;
using System.Manageme nt;
using System.Text;

namespace The_Wifi_Projec t
{
class Program
{
const string wql_listar_adap tadores_conecta dos = "SELECT * FROM
MSNdis_80211_Ba seServiceSetIde ntifier WHERE Active = True";
const string wql_listar_rede s_inalámbricas = "SELECT * FROM
MSNDis_80211_BS SIList";
private static void WIFI_list()
{
/* Establecer una conexión con el entorno de administración */
ManagementScope managementScope = new
ManagementScope ("\\\\.\\root\\ wmi");

System.Manageme nt.ObjectQuery objectQuery = new
System.Manageme nt.ObjectQuery( wql_listar_rede s_inalámbricas );
ManagementObjec tSearcher managementObjec tSearcher = new
ManagementObjec tSearcher(manag ementScope, objectQuery);
ManagementObjec tCollection moc = managementObjec tSearcher.Get() ;
ManagementObjec tCollection.Man agementObjectEn umerator moe =
moc.GetEnumerat or();
moe.MoveNext();
ManagementBaseO bject[] objarr =
(ManagementBase Object[])moe.Current.Pr operties["Ndis80211BSSIL ist"].Value;

if (objarr != null)
{
foreach (ManagementBase Object obj in objarr)
{
char[] ssid =
Encoding.ASCII. GetChars((byte[])obj["Ndis80211S sid"]);
Console.Write(" SSID: ");
int i;
for (i = 0; i < 32 && ssid[i] != '\0'; i++)
{
Console.Write(s sid[i]);
}
uint rs = (uint)obj["Ndis80211R ssi"];
Console.Write(" .");
Console.WriteLi ne(" RSSI: " + rs);
}
}
}

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

foreach (string argumento in args)
{
String argument = argumento.ToLow er();
if (argument.Equal s("list"))
{
WIFI_list();
break;
}
else
{
Console.WriteLi ne("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.

ManagementObjec tSearcher searcher =
new ManagementObjec tSearcher("root \\WMI",
"SELECT * FROM
MSNdis_80211_Se rviceSetIdentif ier");

foreach (ManagementObje ct queryObj in searcher.Get())
{

Console.WriteLi ne("-----------------------------------");

Console.WriteLi ne("MSNdis_8021 1_ServiceSetIde ntifier instance");

Console.WriteLi ne("-----------------------------------");

if(queryObj["Ndis80211S sId"] == null)
Console.WriteLi ne("Ndis80211Ss Id: {0}",
queryObj["Ndis80211S sId"]);
else
{
Byte[] arrNdis80211SsI d = (Byte[])
(queryObj["Ndis80211S sId"]);
foreach (Byte arrValue in arrNdis80211SsI d)
{
Console.WriteLi ne("Ndis80211Ss Id: {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
1461
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 understand the scenario where SEARCH is applicable and where KNOWN is applicable. My question is very basic: >From a server's perspective, what extra is being done at the server to support SEARCH discovery? Are some extra proceeses / threads...
3
3548
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 just doesnt connect and needs to be manually connected. I was wondering if in .net its possible to re connect to the network ? my other smaller problem is that the client code is set to run on start up, a splash screen is initially displayed to...
0
3826
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 on the laptop to access the desktop web service, I get an error message : "The proxy settings on this computer are not configured correctly for Web discovery". The desktop and laptop both have the Windows XP firewall enabled. The internet...
4
6683
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 range? Regards and Thanks, Nitin
7
3812
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 have a discovery process by which applications can discover these services. What I really would like to avoid is static URL's scattered throughout configuration files, and I'm willing to write a fair bit of code to achieve this goal. I had...
4
10338
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 Bluetooth as I can do from Control Panel ("Network and dialup connections" and "Power"). Googling I've found that I should:
0
2115
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 dsl-g604t. A hotspot owner would like to: a) (preferably) identify the ssid of each new operative, and b) have the software enable or disable the new operative access. There is a program which does something similar which probably works on...
4
2244
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 errors message so that i could figure out whats wrong... I searched a little bit in the net and i see also other people having more or less the same problem , but i believe i am very close to the solution , since the wifi card is 'recognised' and...
9
2923
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 and it works fine on wifi at their house (5 blocks away). This makes me think I don't have to forward any ports; just a settings thing ?
0
8402
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8734
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8508
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8608
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.