I'm using a function to return the current WiFi signal strength value given here: http://www.dotnet247.com/247reference/msgs/42/211278.aspx
When I run the code in Visual Studio 2008, I get the compile errors:
Type of namespace 'ManagementObjectSearcher'cannot be found.
I am using 'using System.Manangement'
My over all goal is to acquire the signal strength and plug it into a text box on a windows form, so once I grab the value using the function below, I simply will pop it into the box for the user to see.
Any idea on why I'm getting these errors?
Code:
public static void signalStrentgh()
{
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(@"root\WMI", "select
Ndis80211ReceivedSignalStrength from MSNdis_80211_ReceivedSignalStrength
where active=true");
foreach (ManagementObject mo in searcher.Get())
{
Console.WriteLine("{0}", mo["Ndis80211ReceivedSignalStrength"]);
}
}
Note* Posted below is the old, incorrect version of the code, done in C++. This is in reference to the comments and help.
int GetSignalStrength()
{
ManagementObjectSearcher *searcher = new ManagementObjectSearcher(
"root\\WMI",
"select Ndis80211ReceivedSignalStrength from
MSNdis_80211_ReceivedSignalStrength where active=true");
ManagementObjectCollection *queryCollection = searcher->Get();
ManagementObjectCollection::ManagementObjectEnumer ator* queryEnum =
queryCollection->GetEnumerator();
while (queryEnum->MoveNext());
ManagementBaseObject* object = queryEnum->get_Current();
Object* signalStrength =
object->GetPropertyValue(L"Ndis80211ReceivedSignalStrengt h");
return (Convert::ToInt32(signalStrength->ToString()));
}