VB 版 (精华区)
发信人: student (出去逛逛), 信区: VB
标 题: 监测是否再线
发信站: 哈工大紫丁香 (2001年11月01日09:04:25 星期四), 站内信件
Option Explicit
Public Declare Function RasEnumConnections Lib "RasApi32.dll" Alias "RasEnum
ConnectionsA" (lpRasCon As Any, lpcb As Long, lpcConnections As Long) As Lon
g
Public Declare Function RasGetConnectStatus Lib "RasApi32.dll" Alias "RasGet
ConnectStatusA" (ByVal hRasCon As Long, lpStatus As Any) As Long
Public Const RAS95_MaxEntryName = 256
Public Const RAS95_MaxDeviceType = 16
Public Const RAS95_MaxDeviceName = 32
Public Type RASCONN95
dwSize As Long
hRasCon As Long
szEntryName(RAS95_MaxEntryName) As Byte
szDeviceType(RAS95_MaxDeviceType) As Byte
szDeviceName(RAS95_MaxDeviceName) As Byte
End Type
Public Type RASCONNSTATUS95
dwSize As Long
RasConnState As Long
dwError As Long
szDeviceType(RAS95_MaxDeviceType) As Byte
szDeviceName(RAS95_MaxDeviceName) As Byte
End Type
Public Function IsConnected() As Boolean
Dim TRasCon(255) As RASCONN95
Dim lg As Long
Dim lpcon As Long
Dim RetVal As Long
Dim Tstatus As RASCONNSTATUS95
TRasCon(0).dwSize = 412
lg = 256 * TRasCon(0).dwSize
RetVal = RasEnumConnections(TRasCon(0), lg, lpcon)
If RetVal <> 0 Then
MsgBox "发生错误:因为 " & Err, vbOKOnly + vbCritical, "出错!"
Exit Function
End If
Tstatus.dwSize = 160
RetVal = RasGetConnectStatus(TRasCon(0).hRasCon, Tstatus)
If Tstatus.RasConnState = &H2000 Then
IsConnected = True
Else
IsConnected = False
End If
End Function
Private Sub Timer1_Timer()
If IsConnected = True Then
picConnect(0).Visible = True
picConnect(1).Visible = False
Else
picConnect(1).Visible = True
picConnect(0).Visible = False
End If
End Sub
--
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: student.pact.hit.edu]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.248毫秒