What's Here?
- Members: 300,482
- Replies: 826,138
- Topics: 137,481
- Snippets: 4,420
- Tutorials: 1,148
- Total Online: 1,767
- Members: 78
- Guests: 1,689
|
This is a snippet used to retrieve the WI-FI signal strength of all WI-FI cards attached to your system. Can be used to tell if you are near a WI-FI connection
|
Submitted By: PsychoCoder
|
|
Rating:
 
|
|
Views: 4,279 |
Language: C#
|
|
Last Modified: January 16, 2009 |
|
Instructions: Need a reference to the System.Management Namespace |
Snippet
/// <summary>
/// method for retrieving the signal strength of all WI-FI adapters
/// </summary>
/// <returns></returns>
public static string GetWIFISignalStrength()
{
try
{
ObjectQuery query = new ObjectQuery ("SELECT * FROM MSNdis_80211_ReceivedSignalStrength Where active = true");
ManagementScope scope = new ManagementScope ("root\\wmi");
ManagementObjectSearcher searcher = new ManagementObjectSearcher (scope, query );
string result = "";
foreach (ManagementObject obj in searcher.Get())
{
if ((bool)obj["Active"] == true)
{
result += (string)obj["Ndis80211ReceivedSignalStrength"].ToString() + Environment.NewLine;
}
}
if (result == "")
{
result = "No active WI-FI adapters found!";
}
return result.Trim();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Search Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return string.Empty;
}
}
Copy & Paste
|
|
|
|