Connect and Obtain IP address from DHCP

I am writing an application, which get a list of all network interfaces, with their IP address, MAC address and other info.
The interfaces which are connected with internet have obviously IP addresses. For example, My WLAN interface has IP address. For other interfaces, for example if I plug in a 3G card, it gets IP address when I click the CONNECT button on the software came with this card.
I dont want to use that Software to connect my 3G card and get IP address. Rather I want to enable that interface and get IP address from DHCP server programmatically in C++.
In simplest words I want my network card / adapter should be connected and be assigned IP address using C++.
Note: I am using Windows Vista.
Waiting for reply.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

How about calling the command line tools "netsh" and "ipconfig" shipped with Windows? You can do this from your C++ program.
Here is an example how to change the IP address assignment to DHCP (replace "MyConnection" by the name of your network - see Windows Control Panel):

netsh interface ip set address name="MyConnection" source=dhcp

To reassign the IP address via DHCP after this call:

ipconfig /renew "MyConnection"

Also the command line tool DevCon ( might help you to enable/disable network adapters in the Windows device manager.

Attention: You need real admin rights to do this. On Vista with UAC enabled you need to launch the command line tools with elevation (e.g via ShellExecuteEx or your application already has an according manifest and already runs with real admin rights, see

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.