title: GetInterfaceDnsSettings failed with 87
body: <p>I have a program to set DNS server automatically, but when I used GetInterfaceDnsSettings to get current DNS settings, it always return 87. The code is as followings.</p>
  <pre class="lang-rust prettyprint-override"><code>nsafe fn get_adapters&lt;F&gt;(mut callback: F)
  where
      F: FnMut(&amp;IP_ADAPTER_INFO) -&gt; bool {...}
  #[test]
      fn adapters() {
          unsafe {
              get_adapters(|adapter| {
                  if adapter.Type != 6 || adapter.LeaseObtained == 0 {
                      return false;
                  }
                  let name = get_string(&amp;adapter.AdapterName);
                  println!(
                      &quot;name:{}, dhcp:{}, type:{}, lease:{}&quot;,
                      name, adapter.DhcpEnabled, adapter.Type, adapter.LeaseObtained
                  );
                  let mut guid = GUID::default();
                  let iid: Vec&lt;u16&gt; = adapter
                      .AdapterName
                      .as_slice()
                      .iter()
                      .map(|w| *w as u16)
                      .collect();
                  if S_OK != IIDFromString(iid.as_ptr(), &amp;mut guid) {
                      println!(&quot;IIDFromString failed&quot;);
                      return false;
                  }
                  println!(&quot;guid:{:?}&quot;, guid);
                  let mut setting = DNS_INTERFACE_SETTINGS::default();
                  let code = GetInterfaceDnsSettings(guid, &amp;mut setting);
                  if code == NO_ERROR {
                      println!(&quot;dns:{:?}&quot;, setting.NameServer);
                  } else {
                      println!(&quot;get interface dns failed:{}&quot;, get_error_message(code));
                      return false;
                  }
                  let code = SetInterfaceDnsSettings(guid, &amp;setting);
                  if code != NO_ERROR {
                      println!(&quot;set failed:{}&quot;, get_error_message(code));
                      false
                  } else {
                      true
                  }
              });
          }
      }
  </code></pre>
  <p>Also you can get a full code example in <a href="https://github.com/lazytiger/winapi_test.git" rel="nofollow noreferrer">https://github.com/lazytiger/winapi_test.git</a>
  Need some help, thank you all.</p>