# Re: 关于拨号网路

Posted by Johnny Guo on April 05, 1998 at 08:21:11:

In Reply to: 关于拨号网路 posted by Lily on April 02, 1998 at 19:39:02:

: 不知是否有方法可以测知拨号网路拨接成功或是失败 ?

先宣告如下
Public Const RAS_MaxEntryName = 256
Public Const RAS_MaxDeviceName = 128
Public Const RAS_MaxDeviceType = 16

Type RASCONN
dwSize As Long
hrasconn As Integer
szEntryName(RAS_MaxEntryName + 1) As Byte
szDeviceType(RAS_MaxDeviceType + 1) As Byte
szDeviceName(RAS_MaxDeviceName + 1) As Byte
End Type

Public Declare Function RasEnumConnections& Lib "rasapi32" Alias "RasEnumConnectionsA" (lprasconn As RASCONN, lpcb As Long, lpConnect As Long)

再 call 底下的 function
Private Function AlreadyConnect() As Boolean
Dim Conn() As RASCONN
Dim dl&, size&, validConnection&
ReDim Conn(0)
Conn(0).dwSize = Len(Conn(0))
size = Len(Conn(0))
dl& = RasEnumConnections(Conn(0), size, validConnection)
If dl& = 0 Then
If validConnection > 0 Then
AlreadyConnect = True
Else
AlreadyConnect = False
End If
Else
AlreadyConnect = False
End If
End Function

Follow Ups: