473,386 Members | 1,720 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,386 software developers and data experts.

Can't recognise when connected wirelessly... c# .Net

I have an occasionally connected app, i need to recognise when there is any type of connection to the internal networks, be wired or wireless, however currently if connected wirelessly the app recognises this as offline which is incorrect.

This is the code for the ConnectionManager piece I currently have:
public bool IsNetworkConnected()
{
bool connected = SystemInformation.Network;

if (connected)
{
connected = false;
System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher("SELECT NetConnectionStatus FROM Win32_NetworkAdapter");
foreach (System.Management.ManagementObject networkAdapter in searcher.Get())
{
if (networkAdapter["NetConnectionStatus"] != null)
{
if (Convert.ToInt32(networkAdapter["NetConnectionStatus"]).Equals(2))
{
connected = true;
break;
}
}
}
searcher.Dispose();
}
return connected;
}

Would anyone be able to shed some light as to why it cna't recognise the wireless connection?

Thanks for your help in advance
Jul 11 '07 #1
2 2049
Plater
7,872 Expert 4TB
Is 2 the right value for wireless cards?
2 might mean connected for wired cards, but there might be another value that means "associated" for wireless card?
Jul 11 '07 #2
Good call , but unfortunatly the numbers mean the following

<code> Function NetConnectionStatus(intStatus) Select Case intStatus Case 0 NetConnectionStatus = "Disconnected" Case 1 NetConnectionStatus = "Connecting" Case 2 NetConnectionStatus = "Connected" Case 3 NetConnectionStatus = "Disconnecting" Case 4 NetConnectionStatus = "Hardware not present" Case 5 NetConnectionStatus = "Hardware disabled" Case 6 NetConnectionStatus = "Hardware malfunction" Case 7 strNetConnectionStatus = "Media disconnected" Case 8 NetConnectionStatus = "Authenticating" Case 9 NetConnectionStatus = "Authentication succeeded" Case 10 NetConnectionStatus = "Authentication failed" Case 11 strNetConnectionStatus = "Invalid address" Case 12 NetConnectionStatus = "Credentials required" Case Else NetConnectionSattus = ""

I need it to recognise any type of connection, wireless or wired... and current 2 is not sufficient to recognise the wireless
Jul 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Bill H | last post by:
I used a bit of JS on a page that is fairly long and didn't like the way that <A HREF='#' ONCLICK=\"... refreshed the page to the top. Removing the HREF (<A ONCLICK=\"...) solved my...
3
by: AC | last post by:
Running VS.NET 2003 Enterprise Arch on WinXP Pro SP1 with a P4-2.4Ghz, 760MB+ RAM, and 10+GB free disk space. Laptop is part of a domain. When working on a web project connected at the office,...
1
by: J | last post by:
Hi I've seen a couple of applications which produce a list of all of the devices which have ever been connected to a PC (via USB and FireWire at least), what they were, when they last connected,...
2
by: darthghandi | last post by:
I am trying to pass a socket object when an event is signaled. I have successfully bound to a network interface and listened on a port for incoming connection. I have also been able to accept...
15
by: jim | last post by:
I have a user that uses a built-in wireless ethernet card to connect to our wireless router and surf the internet from behind our router and uses a wireless Sprint card to connect to the internet...
6
by: Bint | last post by:
I have an array whose elements I'm accessing, like array, array, etc. However, the data is meant to be 16-bit words, not bytes. I'm getting byte values right now. Is there any way I can tell php...
1
by: =?Utf-8?B?R2ls?= | last post by:
I have a Dell Dimensions 8200 Desktop(circa 2002) running Windows XP with SP2. I just bought a D-Link DWA-130 Wireless N USB Adapter and I am trying to connect this set up to a Mac Airport Extreme...
1
by: Ryan Liu | last post by:
Hi, I have a 100 clients/ one server application, use ugly one thread pre client approach. And both side user sync I/O. I frequently see the error on server side(client side code is same, but...
11
by: casucci | last post by:
I do a return as XMLDataDocument in my webservice but it returns not with the namespaces etc in them. Anyone have and example where I can have the webservice return it as a XML. C# preferred....
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: 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
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.