1个回答
2013-09-08
展开全部
两个命令按钮,一个text,一个timer代码:Dim t As Integer
Private Sub Command1_Click()
t = Text1.Text
MsgBox "系统将在" & t & "分钟后自动断开网络连接"
Timer1.Enabled = True
Me.Hide
End SubPrivate Sub Command2_Click()
Me.Hide
End SubPrivate Sub Form_Load()
App.TaskVisible = False
Timer1.Enabled = False
Timer1.Interval = 60000
Dim ret As Long
preWinProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)
ret = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf Wndproc)
idHotKey = 1
Modifiers = MOD_CONTROL
uVirtKey = vbKeyA
ret = RegisterHotKey(Me.hwnd, idHotKey, Modifiers, uVirtKey)
End Sub Private Sub Timer1_Timer()
t = t - 1
If t <= 0 Then
Shell "Rasdial /DISCONNECT"
End If
End Sub 然后再把以下代码写到模块中:Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function CallWindowProc Lib "User32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function RegisterHotKey Lib "User32" (ByVal hwnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Declare Function UnregisterHotKey Lib "User32" (ByVal hwnd As Long, ByVal id As Long) As LongPublic Const WM_HOTKEY = &H312
Public Const MOD_ALT = &H1
Public Const MOD_CONTROL = &H2
Public Const MOD_SHIFT = &H4
Public Const GWL_WNDPROC = (-4)Public preWinProc As Long
Public Modifiers As Long, uVirtKey As Long, idHotKey As LongPrivate Type taLong
ll As Long
End TypePrivate Type t2Int
lWord As Integer
hWord As Integer
End TypePublic Function Wndproc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_HOTKEY Then
If wParam = idHotKey Then
Dim lp As taLong, i2 As t2Int
lp.ll = lParam
LSet i2 = lp
If (i2.lWord = Modifiers) And i2.hWord = uVirtKey Then
Form1.Show
End If
End If
End If
Wndproc = CallWindowProc(preWinProc, hwnd, Msg, wParam, lParam)
End Function OK,完工了在这个软件的text1中输入你想要断开网络的时间,然后按下command1,窗体就会自动隐藏,按下“Ctrl + A”可以再次弹出窗体(command2只是怕不小心按下Ctrl + A后无法再次隐藏窗体而设计的,按下它就可以再次隐藏窗体)断开网络连接后,如果没有关掉此软件,再次连接网咯时,系统会在1分钟内再次断开网络,这样别人就对你的电脑没辙了,哈哈。望采纳
Private Sub Command1_Click()
t = Text1.Text
MsgBox "系统将在" & t & "分钟后自动断开网络连接"
Timer1.Enabled = True
Me.Hide
End SubPrivate Sub Command2_Click()
Me.Hide
End SubPrivate Sub Form_Load()
App.TaskVisible = False
Timer1.Enabled = False
Timer1.Interval = 60000
Dim ret As Long
preWinProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)
ret = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf Wndproc)
idHotKey = 1
Modifiers = MOD_CONTROL
uVirtKey = vbKeyA
ret = RegisterHotKey(Me.hwnd, idHotKey, Modifiers, uVirtKey)
End Sub Private Sub Timer1_Timer()
t = t - 1
If t <= 0 Then
Shell "Rasdial /DISCONNECT"
End If
End Sub 然后再把以下代码写到模块中:Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function CallWindowProc Lib "User32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function RegisterHotKey Lib "User32" (ByVal hwnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
Declare Function UnregisterHotKey Lib "User32" (ByVal hwnd As Long, ByVal id As Long) As LongPublic Const WM_HOTKEY = &H312
Public Const MOD_ALT = &H1
Public Const MOD_CONTROL = &H2
Public Const MOD_SHIFT = &H4
Public Const GWL_WNDPROC = (-4)Public preWinProc As Long
Public Modifiers As Long, uVirtKey As Long, idHotKey As LongPrivate Type taLong
ll As Long
End TypePrivate Type t2Int
lWord As Integer
hWord As Integer
End TypePublic Function Wndproc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_HOTKEY Then
If wParam = idHotKey Then
Dim lp As taLong, i2 As t2Int
lp.ll = lParam
LSet i2 = lp
If (i2.lWord = Modifiers) And i2.hWord = uVirtKey Then
Form1.Show
End If
End If
End If
Wndproc = CallWindowProc(preWinProc, hwnd, Msg, wParam, lParam)
End Function OK,完工了在这个软件的text1中输入你想要断开网络的时间,然后按下command1,窗体就会自动隐藏,按下“Ctrl + A”可以再次弹出窗体(command2只是怕不小心按下Ctrl + A后无法再次隐藏窗体而设计的,按下它就可以再次隐藏窗体)断开网络连接后,如果没有关掉此软件,再次连接网咯时,系统会在1分钟内再次断开网络,这样别人就对你的电脑没辙了,哈哈。望采纳
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询