老文章档案 · 2003 年

解除网虫的心病 用VB做定时断线程序

破解教程 · 汇编专区 · 2003-10-08 · 作者:人气: · 出处:赢政天下整理收藏)

作为网虫,最头疼的事情之一就是每月高额的电话费。笨笨也是一样,每个月都想着少上一会儿网,然而银子仍然像流水一样飞逝……一天,笨笨突然想到了VB中有一个强大的时间控件——Timer,为什么不做一个能定时断开连接的程序呢?经过了一番研究和N次的调试,笨笨终于成功了。不敢独占,拿来和大家一起分享,也解救一下为了网费而过得“水深火热”的网虫。

运行VB 6,向窗体添加7个Label控件、1个Timer控件、3个Text文本输入框以及4个Command按钮(如图1)。

原理简介:用Timer控件的True或者False值,控制倒计时的开始,当到达设定时间的时候,弹出对话框提示断开连接。

Option Explicit

Dim Hours As Integer

Dim Minutes As Integer

Dim Seconds As Integer

Dim time As Date

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

dwSize As Long

hRasConn As Long

szEntryName(RAS95_MaxEntryName) As Byte

szDeviceType(RAS_MaxDeviceType) As Byte

szDeviceName(RAS95_MaxDeviceName) As Byte

End Type

下面一段代码是对Timer的控制,以及到设定时间的时候断开连接的代码

Private Sub Timer1_Timer()

Timer1.Enabled = False

If (Format100 100time, "hh") && ":" && Format100 100time, "nn") && ":" && Format100 100time, "ss"))〈〉"00:00:00" Then

time = DateAdd("s", -1, time)

Label1.Visible = False

Label1.Caption = Format100 100time, "hh") && ":" && Format100 100time, "nn") && ":" && Format100 100time, "ss")

Label1.Visible = True

Timer1.Enabled = True

Else

Timer1.Enabled = False

End If

If Label1.Caption = "00:00:01" Then

dsdklj.WindowState = 0

Command1.Enabled = True

MsgBox "时间到了,正在断开连接"

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

Unload Me

Else

MsgBox "时间到了,没有拨号网络连接"

Unload Me

End If

End If

End If

End Sub

其实,这个程序还可以进一步的完善,比如添加暂停功能、或者经过改造,适用于宽带的,等等。这不,笨笨拿着电话单正偷着乐呢!笨笨已经利用这个小程序省下了不少网费,你呢?

(出处:赢政天下整理收藏)

相关文章:

相关软件:

→ 特别推荐

→ 热点TOP10

我为人人《《==》》人人为我

关于我们 |

帮助(?)

| 广告服务 |

版权声明 |

商业合作 |

发展历程 |

加盟我们 |

联系我们

Copyright © 1999-2003

winzheng.com All Rights Reserved.

繁体版:由华琦数码技术提供

Powered

by:MeSky.Net

2003-2004 年,宽带刚刚普及,下载站的文章区是许多人学电脑的第一课堂。
🕰 → 🤖 从那时到现在

当年一篇教程能让一台电脑焕然一新;今天的效率工具换成了 AI。 想知道当下最可靠的 AI 模型怎么选?看 赢政指数——我们用了 28 年的选软件严谨,现在用来评测大模型。

档案性质声明:本页为赢政天下(1998-2011)老文章的历史档案复原, 内容反映当年发表时的原貌——包括当年的技术表述、软件版本与观点,部分方法在今天已不适用或不合规,仅作互联网历史记录与研究用途, 不提供任何形式的下载。原始数据经由公共网络存档(Internet Archive)复原。发现问题请联系我们
← 返回老文章档案 · 软件史档案馆 · 赢政天下站史