//Disable Setnetworkadapter (False)//enable Setnetworkadapter (True)//Add Reference System32/shell32.dll Private Static BOOLSetnetworkadapter (BOOLstatus) { Const stringDiscverb ="Deactivate (&b)";//"Deactivate (&b)"; Const stringConnverb ="enabled (&a)";//"enabled (&a)"; Const stringNetwork ="Network Connection";//"Network connection"; Const stringNetworkconnection ="VMware Network Adapter VMnet1";//"Local Area Connection" stringSverb =NULL; if(status) {Sverb=Connverb; } Else{Sverb=Discverb; } Shell32.shell SH=NewShell32.shell (); Shell32.folder Folder=Sh. NameSpace (Shell32.ShellSpecialFolderConstants.ssfCONTROLS); Try { //all options to access the control Panel foreach(Shell32.folderitem myiteminchfolder. Items ()) {//go to network connection if(Myitem.name = =Network) {Shell32.folder FD=(Shell32.folder) Myitem.getfolder; foreach(Shell32.folderitem fiinchFD. Items ()) {//Find Local Area Connection if(FI. Name = =networkconnection)) { //Find all right-click menus for local connections foreach(Shell32.folderitemverb Fibinchfi. Verbs ()) {if(Fib.name = =Sverb) {Fib.doit (); return true; } } } } } } } Catch(Exception e) {Console.WriteLine (e.message); return false; } return true; }
Source: http://blog.csdn.net/leon_ice/article/details/4426278
Shell32.dll Control Network