I'm trying to write a program that will switch the selected adapter's IP on command.
For that, i'm using the GetAdaptersInfo() function to get the adapter's Index and it's IP context, and then using that to delete the current IP (through DeleteIPAddress(context)).
After that, the new IP would be inserted through AddIPAddress().
The problem is, the call to the DeleteIPAddress function fails when trying to delete the "default" IP (the one not set by AddIPAddress()) and calling AddIPAddress before deleting the old IP just leaves the adapter with two different simultaneous IPs.
The DeleteIPAddress function fails with error 31 (A device attached to the system is not functioning).
Is there another way to sucessfully change the IP Address on an adapter? Is DeleteIPAddress actually usable without getting context from AddIPAddress?