How to remove a static IP configuration for an absent network adapter through WinAPI?

3.8k Views Asked by At

When you configure a network adapter with a certain IP address that was already used before on a currently removed network adapter, you will fail.

If you do this trough the Windows TCP/IP settings GUI, you will be alerted and offered the option to remove the old adapter IP configuration.

How can you achieve the same result trough WinAPI ?

If I use the IP Helper functions (GetAdaptersAddresses, GetAdaptersInfo), they only return the connected adapters.

If I use the Win32_NetworkAdapterConfiguration WMI class by executing the query:

"Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = False"

I get only the disconnected devices, which is perfect, but the "IPAddress" property is empty.

So how can one configure a network adapter with an IP address that was used before by another network adapter which is now not present anymore, through WinAPI ?

0

There are 0 best solutions below