Changing TCP/IP Properties from code

JumpyNET

Centurion
Joined
Apr 4, 2005
Messages
196
Is it possible to change the TCP/IP Properties from code?

I need to toggle between the settings "Obtain an IP address automatically" and "Use the following address:". And for the latter one I need to specify the "IP address:" and "Subnet mask:". Any ideas?

For clarity I attached a picture.
 

Attachments

WMI = System.Management

From a quick glance at the class, it looks like you would use the methods EnableDHCP (for obtaining an address automatically) and EnableStatic (for using a set address). Since this is a WMI class you will need to use the classes in the System.Management namespace (reference System.Management.dll) to wrap and interact with the WMI object. Having not worked with this much myself I'll leave it for someone more knowledgeable to explain this part, though it all looks fairly straightforward.

Good luck. :)
 
Back
Top