自动断网 VB代码

发布时间:2024-11-01 07:14 发布:上海旅游网

问题描述:

我现在想要用VB做个程序:
设置一个时间段,只要在这个时间段之内的话网络可以连接,可以正常上网,但是超过了这个时间段,就算电脑重新启动,也无法连接上网,高手啊!!!

问题解答:

有个拨号的
Option Explicit
Private Declare Function RasHangUp Lib "RasApi32.DLL" Alias "RasHangUpA" (ByVal hRasConn As Long) As Long
Private Declare Function RasEnumConnections Lib "RasApi32.DLL" Alias "RasEnumConnectionsA" (lprasconn As Any, lpcb As Long, lpcConnections As Long) As Long

Const RAS95_MaxEntryName = 256
Const RAS95_MaxDeviceName = 128
Const RAS_MaxDeviceType = 16

Private Type RASCONN95
'set dwsize to 412
dwSize As Long
hRasConn As Long
szEntryName(RAS95_MaxEntryName) As Byte
szDeviceType(RAS_MaxDeviceType) As Byte
szDeviceName(RAS95_MaxDeviceName) As Byte
End Type

Private Sub Command1_Click()
Dim lngRetCode As Long
Dim lpcb As Long
Dim lpcConnections As Long
Dim intArraySize As Integer
Dim intLooper As Integer

ReDim lprasconn95(intArraySize) As RASCONN95
lprasconn95(0).dwSize = 412
lpcb = 256 * lprasconn95(0).dwSize
lngRetCode = RasEnumConnections(lprasconn95(0), lpcb, lpcConnections)

If lngRetCode = 0 Then
If lpcConnections > 0 Then
For intLooper = 0 To lpcConnections - 1
RasHangUp lprasconn95(intLooper).hRasConn
Next intLooper
Else
MsgBox "没有拨号网络连接!", vbInformation
End If
End If
End Sub

这个貌似有点难度,VB的话,联网和断网都可以做到,但你的这个要涉及到系统的限制,具体怎么个限制法好像很难绝对保证不能上网,除非你干脆做个网吧管理系统

热点新闻