views:

56

answers:

1

Hi,

on Windows 7 I can enable and disable connections via the Network Connections Manager panel (in system settings).

How can I do this programmatically in C#? Thanks

+5  A: 

You can achieve this in C# by leveraging WMI and the Win32_NetworkAdapter WMI class. The Win32_NetworkAdapter class has Enable and Disable methods which can be executed on a selected network interface.

An example of usage can be found here:

http://blog.opennetcf.com/ncowburn/2008/06/24/HOWTODisableEnableNetworkConnectionsProgrammaticallyUnderVista.aspx

chibacity