Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to disabled network adapter !!!!?

Status
Not open for further replies.

tarekmomtaz

Programmer
Feb 26, 2016
1
EG
hello everyone
how i can disabled/enabled NetworkAdapter using vfp code
thank's for help
 
Jockey2,

There is no article linked in your reply.

B-(

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Depending on the version of windows you have, this may work (This example enables the network connection, just reverse the action)

Code:
Public Array aconnections[1]
aconnections[1]=''
LOCAL singleconnection
 i = 1
 o = Createobject("Shell.Application")
 ns=o.NameSpace (3)
For Each oItems In  ns.Items
   If oItems.Name ="Network Connections"  && Windows Anglais
     colNetwork = oItems.getfolder
     If Vartype(colNetwork) = "O"
       For Each colConn In colNetwork.Items
         If Alen(aconnections)= 1 And Empty(aconnections[1])
         Else
           Dimension aconnections[ALEN(aconnections)+1]
         Endif
         aconnections[i]=colConn.Name
         i = i +1
       Next
     Endif
   Endif
Next
For i = 1 To Alen(aconnections)
   If "Titan" $ aconnections[i]  &&Un example
     Connect(aconnections[i])
   Endif
Next
Function Connect(lcConnexion)
For Each colConn In colNetwork.Items
   If colConn.Name = lcConnexion
     singleconnection = colConn
     Exit
   Endif
Next
For Each clsVerb In singleconnection.Verbs
     If "C&onnect" = clsVerb.Name Or "En&able" = clsVerb.Name
       Try
         singleconnection.InvokeVerb("C&onnect")
       Catch
         singleconnection.InvokeVerb("En&able")
       ENDTRY
     Endif
   Next
Endfunc

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top