title: WiFi Signal Strength function with compile errors
body: <p>I'm using a function to return the current WiFi signal strength value given here:   <a href="http://www.dotnet247.com/247reference/msgs/42/211278.aspx" rel="nofollow">http://www.dotnet247.com/247reference/msgs/42/211278.aspx</a> </p>
  
  <p>When I run the code in Visual Studio 2008, I get the compile errors:</p>
  
  <p>Type of namespace 'ManagementObjectSearcher'cannot be found.</p>
  
  <p>I am using 'using System.Manangement'</p>
  
  <p>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.</p>
  
  <p>Any idea on why I'm getting these errors?</p>
  
  <p>Code:</p>
  
  <pre><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"]);
              }
          }
  </code></pre>
  
  <p>Note* Posted below is the old, incorrect version of the code, done in C++. This is in reference to the comments and help.</p>
  
  <pre><code>int GetSignalStrength()
  {
    ManagementObjectSearcher *searcher = new ManagementObjectSearcher(
    "root\\WMI",
    "select Ndis80211ReceivedSignalStrength from
    MSNdis_80211_ReceivedSignalStrength where active=true");
  
    ManagementObjectCollection *queryCollection = searcher-&gt;Get();
  
    ManagementObjectCollection::ManagementObjectEnumer ator* queryEnum =
    queryCollection-&gt;GetEnumerator();
    while (queryEnum-&gt;MoveNext());
  
    ManagementBaseObject* object = queryEnum-&gt;get_Current();
    Object* signalStrength =
    object-&gt;GetPropertyValue(L"Ndis80211ReceivedSignalStrengt h");
    return (Convert::ToInt32(signalStrength-&gt;ToString()));
  }
  </code></pre>