3

How change I change the network settings (IP address, DNS Server, Gateway, DHCP server) from C not C++, also preferably with windows api calls and not WMI.

Thanks!

2
  • Lol, how do you get that idea? It's actually the opposite: I'm writing a program that fixes my internet connection. Apparently my DNS server is very flakey and so my program is going to detect that behaviour and switch the DNS to a TLD while the local DNS is down. I hope to expand it to other problems later and hence the want to change other settings. Commented Dec 14, 2010 at 19:05
  • was you successful using this class for setting IP address, DNS Server, Gateway, DHCP server...i am facing hell a lot of trouble need some guidence Commented Nov 27, 2013 at 0:59

1 Answer 1

4

Check out the IP Helper API.

The Internet Protocol Helper (IP Helper) API enables the retrieval and modification of network configuration settings for the local computer.

Sign up to request clarification or add additional context in comments.

3 Comments

Wow, thanks for the fast response! One sub-question though: •Managing Network Adapters Using GetAdaptersInfo •Managing Interfaces Using GetInterfaceInfo •Managing IP Addresses Using GetIpAddrTable are three methods listed there. Why would I prefer one method over another?
@SteveTownsend : using this class for setting IP address, DNS Server, Gateway, DHCP server...i am facing hell a lot of trouble need some guidence
@Ragav - are you checking for all returned error codes? Win32 APIs are sometimes brittle to bad inputs, and you must check the return code as documented in MSDN every time you call a Win32 API. Otherwise, I'd suggest parceling up your failing code into a new question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.