473,763 Members | 7,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

3 New Member
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 ConnectionManag er piece I currently have:
public bool IsNetworkConnec ted()
{
bool connected = SystemInformati on.Network;

if (connected)
{
connected = false;
System.Manageme nt.ManagementOb jectSearcher searcher = new System.Manageme nt.ManagementOb jectSearcher("S ELECT NetConnectionSt atus FROM Win32_NetworkAd apter");
foreach (System.Managem ent.ManagementO bject networkAdapter in searcher.Get())
{
if (networkAdapter["NetConnectionS tatus"] != null)
{
if (Convert.ToInt3 2(networkAdapte r["NetConnectionS tatus"]).Equals(2))
{
connected = true;
break;
}
}
}
searcher.Dispos e();
}
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 2066
Plater
7,872 Recognized Expert Expert
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
Anne150585
3 New Member
Good call , but unfortunatly the numbers mean the following

<code> Function NetConnectionSt atus(intStatus) Select Case intStatus Case 0 NetConnectionSt atus = "Disconnect ed" Case 1 NetConnectionSt atus = "Connecting " Case 2 NetConnectionSt atus = "Connected" Case 3 NetConnectionSt atus = "Disconnect ing" Case 4 NetConnectionSt atus = "Hardware not present" Case 5 NetConnectionSt atus = "Hardware disabled" Case 6 NetConnectionSt atus = "Hardware malfunction" Case 7 strNetConnectio nStatus = "Media disconnected" Case 8 NetConnectionSt atus = "Authenticating " Case 9 NetConnectionSt atus = "Authentica tion succeeded" Case 10 NetConnectionSt atus = "Authentica tion failed" Case 11 strNetConnectio nStatus = "Invalid address" Case 12 NetConnectionSt atus = "Credential s required" Case Else NetConnectionSa ttus = ""

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
2888
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 "problem" however the cursor no longer changes into the little hand when rolling over the link. Can I have both? No HREF and the little hand?
3
2543
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, VS.NET enters into debug mode (compiling, firing off a browser, and starting the debugger) just fine. However, when the machine is disconnected, or I'm working off a wireless network @ home (WiFi) or working off a wired connection @ home (all...
1
1100
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, if they're still connected and so on. I'd like to have a go at implementing something like this myself - does anyone know the APIs to use to do this?
2
4947
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 that connection and get the socket. I try to signal an event when this happens and pass that new socket object when the event happens, but when I try to pass the socket with this statement: ConnectionReceived(this, work); I get this exception in...
15
1600
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 when not in the office. I need to be able to detect when he is connected from the office and when he is connected via the Sprint card. Monitoring the status of the Local Area Connection may not be the best solution because he may use it to...
6
1549
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 that an array is composed of words and not bytes? Thanks B
1
1358
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 wireless Router. The PC recognizes the wireless signal and correctly identifies the network. However, when I attempt to connect, the PC does not connect. I have a Toshiba laptop running Windows XP with SP2 that connected to the network without...
1
20642
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 I don't see the error): "System.IO.IOException: Unable to read data from the transport connection:A blocking operation was interrupted by a call to WSACancelBlockingCall"
11
2898
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. Flash just sees it as an object when it calls the web service. Thanks
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10144
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9997
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...
0
8821
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7366
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5270
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
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
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.