How to tell a network interface to use DHCP programmically?


  • Is there an API function that does the same as "netsh interface ipv4 set address <interface> dhcp"?
    • Edited by IffIfanoff Sunday, February 17, 2013 8:40 PM
    • Moved by Jesse Jiang Monday, February 18, 2013 8:21 AM
    Sunday, February 17, 2013 8:27 PM

All replies

  • You want the IP Helper API.   SetUnicastIpAddressFunction.

    Sunday, February 17, 2013 11:07 PM
  • I think you mean SetUnicastIpAddressEntry. However, could you give me a little example of using this function? I've examined it before, but I couldn't get how to do it. As I can see it takes Address and OnLinkPrefixLength, which together form a concrete IP address. So it's suitable to give an interface a known IP, but what should I do with MIB_UNICASTIPADDRESS_ROW members to command an interface to get an IP from a DHCP?
    Sunday, February 17, 2013 11:34 PM
  • Hello,
    Welcome here.
    Based on your description, I’d like to move this thread to a more appropriate forum: Windows Desktop SDK.
    Thanks for your understanding.


    Elegentin Xie
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 18, 2013 8:26 AM