vb怎么编写断开网络和连接网络? 30

希望不要用上宽带连接的帐户名和密码。我想应该是可以做到的。不然,金山毒霸及其它杀软怎么可以做到?它们也没有用到用户提供的帐号和密码一样可以断开连接···我想VB应该不会写... 希望不要用上宽带连接的帐户名和密码。我想应该是可以做到的。不然,金山毒霸及其它杀软怎么可以做到?它们也没有用到用户提供的帐号和密码一样可以断开连接···我想VB应该不会写不出来吧?
ydm你写的什么程序!搞得我以为可以断开了网络,刷新了几次百度还是可以连接得上!又登了几次QQ依然可以登!这就叫断开网络?按按钮2时还卡得QQ都变白色的了!太烂的代码,不知道从哪个垃圾桶里拾出来的···
展开
 我来答
ydm_bd
2011-01-17 · TA获得超过884个赞
知道小有建树答主
回答量:195
采纳率:0%
帮助的人:99.1万
展开全部
Option Explicit

Private Const NO_ERROR As Long = 0

Private Const MAX_ADAPTER_NAME As Long = 256

Private Type IP_ADAPTER_INDEX_MAP
Index As Long
wsName As String * MAX_ADAPTER_NAME
End Type

Private Type IP_INTERFACE_INFO
NumAdapters As Long
Adapter(0) As IP_ADAPTER_INDEX_MAP
End Type

Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)

Private Declare Function IpReleaseAddress Lib "IPHLPAPI.dll" (ByRef AdapterInfo As IP_ADAPTER_INDEX_MAP) As Long
Private Declare Function IpRenewAddress Lib "IPHLPAPI.dll" (ByRef AdapterInfo As IP_ADAPTER_INDEX_MAP) As Long

Private Declare Function GetInterfaceInfo Lib "IPHLPAPI.dll" (ByRef pIfTable As Any, ByRef dwOutBufLen As Long) As Long

Private Sub Command1_Click()
Dim i As Long, lOut As Long, lNum As Long
Dim III As IP_INTERFACE_INFO, arrTmp() As Byte
Dim aIAIM() As IP_ADAPTER_INDEX_MAP, IAIM As IP_ADAPTER_INDEX_MAP
i = GetInterfaceInfo(III, lOut)
ReDim arrTmp(lOut - 1)
i = GetInterfaceInfo(arrTmp(0), lOut)
If i <> NO_ERROR Then Exit Sub
CopyMemory lNum, arrTmp(0), 4
Debug.Print lNum; " Network Interface(s) Total!!!"
ReDim aIAIM(lNum - 1)
For i = 0 To lNum - 1
CopyMemory aIAIM(i), arrTmp(4 + i * Len(IAIM)), Len(IAIM)
Debug.Print "Index:"; aIAIM(i).Index; " Name:"; StrConv(aIAIM(0).wsName, vbFromUnicode)
Next

Debug.Print IpReleaseAddress(aIAIM(0)) '断开第一个网卡
End Sub

Private Sub Command2_Click()
Dim i As Long, lOut As Long, lNum As Long
Dim III As IP_INTERFACE_INFO, arrTmp() As Byte
Dim aIAIM() As IP_ADAPTER_INDEX_MAP, IAIM As IP_ADAPTER_INDEX_MAP
i = GetInterfaceInfo(III, lOut)
ReDim arrTmp(lOut - 1)
i = GetInterfaceInfo(arrTmp(0), lOut)
If i <> NO_ERROR Then Exit Sub
CopyMemory lNum, arrTmp(0), 4
Debug.Print lNum; " Network Interface(s) Total!!!"
ReDim aIAIM(lNum - 1)
For i = 0 To lNum - 1
CopyMemory aIAIM(i), arrTmp(4 + i * Len(IAIM)), Len(IAIM)
Debug.Print "Index:"; aIAIM(i).Index; " Name:"; StrConv(aIAIM(0).wsName, vbFromUnicode)
Next

Debug.Print IpRenewAddress(aIAIM(0)) '恢复第一个网卡
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式