Use Win API to set EnableDHCP flag

Dear expert,

I need to use Win APIs to set value for EnableDHCP flag.
But it seems I can not find the API to do this.
So, is there any API for doing this? Please help me to find this.

Note: until now, I can use Win API to set value for IPAddress , DefaultGateway and SubnetMask.

Who is Participating?
jkrConnect With a Mentor Commented:
There should be two ways, either using WMI and ("EnableDHCP method of the Win32_NetworkAdapterConfiguration class") or calling 'SetIpInterfaceEntry()' ( with 'ManagedAddressConfigurationSupported' set to TRUE.
the EnableDHCP flag is a registry REG_DWORD below


where xxxxxxxx-yyyy-zzzz-aaaa-bbbbbbbbbbbb is the GUID of the LAN connection.

you find the GUID below


note, the GUID would not change as long as you don't add/remove network adapters or their connections.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.