title: Using the iphlpapi.dll in .Net to Add new IP Addresses on x64 machines
body: <p>I am using this code to add IP addresses to a nic card:</p>
  
  <pre><code>[DllImport("iphlpapi.dll", SetLastError = true)]
          private static extern UInt32 AddIPAddress(UInt32 address, UInt32 ipMask, int ifIndex, out IntPtr nteContext,
                                                    out IntPtr nteInstance);
  
  public static UInt32 AddIpAddressToInterface(string ipAddress, string subnetMask, int ifIndex)
          {
              var ipAdd = System.Net.IPAddress.Parse(ipAddress);
              var subNet = System.Net.IPAddress.Parse(subnetMask);
              unsafe
              {
                  var nteContext = 0;
                  var nteInstance = 0;
                  IntPtr ptrNteContext;
                  var ptrNteInstance = new IntPtr(nteInstance);
                  return AddIPAddress((uint)BitConverter.ToInt32(ipAdd.GetAddressBytes(), 0), (uint)BitConverter.ToInt32(subNet.GetAddressBytes(), 0), ifIndex, out ptrNteContext,
                                      out ptrNteInstance);
              }
          }
  </code></pre>
  
  <p>It seems to be working, but I noticed if I reboot the machine, the IPs are removed. Also, I can see them if I perform an ipconfig from a command line, but I do not see them in the Advanced TCP/IP settings dialog. So, are the IPS really added or do I need do something else to ensure the IPs are bound to the nic card?</p>
  
  <p><img src="https://i.stack.imgur.com/UXYOa.png" alt="IP Addresses via command line"></p>
  
  <p><img src="https://i.stack.imgur.com/tWXmO.png" alt="enter image description here"></p>