设为首页设为首页
 添加收藏添加收藏
 进入音乐版音 乐 版
  汉南在线程序设计VB程序

解除网虫心病VB做定时断线程序
作  者:匿名
关键字:VisualBasic实例



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



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

  OptionExplicit

  DimHoursAsInteger

  DimMinutesAsInteger

  DimSecondsAsInteger

  DimtimeAsDate

  PrivateDeclareFunctionRasHangUpLib"RasApi32.dll"Alias"RasHangUpA"(ByValhRasConnAsLong)AsLong

  PrivateDeclareFunctionRasEnumConnectionsLib"RasApi32.dll"Alias"RasEnumConnectionsA"(lprasconnAsAny,lpcbAsLong,lpcConnectionsAsLong)AsLong

  ConstRAS95_MaxEntryName=256

  ConstRAS95_MaxDeviceName=128

  ConstRAS_MaxDeviceType=16

  PrivateTypeRASCONN95

  dwSizeAsLong

  hRasConnAsLong

  szEntryName(RAS95_MaxEntryName)AsByte

  szDeviceType(RAS_MaxDeviceType)AsByte

  szDeviceName(RAS95_MaxDeviceName)AsByte

  EndType

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

  PrivateSubTimer1_Timer()

  Timer1.Enabled=False

  If(Format100100time,"hh")&&":"&&Format100100time,"nn")&&":"&&Format100100time,"ss"))〈〉"00:00:00"Then

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

  Label1.Visible=False

  Label1.Caption=Format100100time,"hh")&&":"&&Format100100time,"nn")&&":"&&Format100100time,"ss")

  Label1.Visible=True

  Timer1.Enabled=True

  Else

  Timer1.Enabled=False

  EndIf

  IfLabel1.Caption="00:00:01"Then

  dsdklj.WindowState=0

  Command1.Enabled=True

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

  DimlngRetCodeAsLong

  DimlpcbAsLong

  DimlpcConnectionsAsLong

  DimintArraySizeAsInteger

  DimintLooperAsInteger

  ReDimlprasconn95(intArraySize)AsRASCONN95

  lprasconn95(0).dwSize=412

  lpcb=256*lprasconn95(0).dwSize

  lngRetCode=RasEnumConnections(lprasconn95(0),lpcb,lpcConnections)

  IflngRetCode=0Then

  IflpcConnections〉0Then

  ForintLooper=0TolpcConnections-1

  RasHangUplprasconn95(intLooper).hRasConn

  NextintLooper

  UnloadMe

  Else

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

  UnloadMe

  EndIf

  EndIf

  EndIf

  EndSub

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



来源:网络
阅读:598
日期:2008-1-2

【 双击滚屏 】 【 收藏 】 【 打印 】 【 关闭 】 【 字体: 】 
上一篇:怎样限制鼠标移动
下一篇:VB中任意旋转位图的实现

  >> 相关文章
 
  ·怎样限制鼠标移动
  ·VisualBasic菜单在应用程序中的使用
  ·利用API函数实现隐藏和显示桌面图标
  ·用VB实现“ICQ”式的启动欢迎画面
  ·再谈VB程序的加密
  ·多用户应用程序中应注意的其它问题(1)--多客户环境下VB数据库编程之(8)
  ·VB5实现窗口图像缩放、滚动技巧
  ·用VisualBasic自编小游戏
授权使用:汉南在线 http://www.hzwz.net/(2008-2009)   
Copyright (c) 2002-2007 汉南在线. All Rights Reserved . 
经营许可证:陕ICP备05000109号 Powered by:汉南在线