请问在win10中,怎么用vb控制网卡呢?下面是xp中控制网卡
"网络连接" 文件夹在xp和win10中的位置不一样,win10中如果在oControlPanel.Items中找 网络连接 文件夹是找不到的,该怎么修改呢?谢谢!Const ssfCONTROLS = 3
sConnectionName = "内" '可改成需要控制的连接名称,如"无线网络连接"等
sEnableVerb = "启用(&A)"
sDisableVerb = "停用(&B)" 'XP系统中应为 "停用(&B)"、 "禁用(&B)"
Set shellApp = CreateObject("shell.application")
Set oControlPanel = shellApp.Namespace(ssfCONTROLS)
Set oNetConnections = Nothing
For Each folderitem In oControlPanel.Items
If folderitem.Name = "网络连接" Then
Set oNetConnections = folderitem.GetFolder: 'Exit For
End If
MsgBox folderitem.Name
Next
Exit Sub
If oNetConnections Is Nothing Then
MsgBox "未找到网络连接文件夹"
wscript.Quit
End If
Set oLanConnection = Nothing
For Each folderitem In oNetConnections.Items
If LCase(folderitem.Name) = LCase(sConnectionName) Then
Set oLanConnection = folderitem: Exit For
End If
Next
If oLanConnection Is Nothing Then
MsgBox "未找到 '" & sConnectionName & "' item"
wscript.Quit
End If
bEnabled = True
Set oEnableVerb = Nothing
Set oDisableVerb = Nothing
s = "Verbs: " & vbCrLf
For Each Verb In oLanConnection.verbs
s = s & vbCrLf & Verb.Name
If Verb.Name = sEnableVerb Then
Set oEnableVerb = Verb
bEnabled = False
End If
If Verb.Name = sDisableVerb Then
Set oDisableVerb = Verb
End If
Next
If bEnabled Then
' oLanConnection.invokeverb sDisableVerb
oDisableVerb.DoIt
Text43.Text = Text43.Text & Time() & vbCrLf
Label96.ForeColor = &HFF&
ElseIf bEnabled = False Then
' oLanConnection.invokeverb sEnableVerb
oEnableVerb.DoIt
End If