# Re: 我只会开,不会关ㄝ,怎么办....

Posted by Lai on November 23, 1998 at 12:00:12:

In Reply to: Re: 我只会开,不会关ㄝ,怎么办.... posted by Honey on November 21, 1998 at 23:32:29:

: 首先得在一般宣告中宣告两个API
: Private Declare Function _
: RasEnumConnections _
: Lib "rasapi32.dll" Alias _
: "RasEnumConnectionsA" _
: (lpRasConn As Any, lpcb As _
: Long, lpcConnections _
: As Long) As Long

: Private Declare Function _
: RasHangUp Lib "rasapi32.dll" _
: Alias "RasHangUpA" _
: (ByVal hRasConn As _
: Long) As Long
: '若在模组宣告得去掉Private

: 之后宣告些常数,宣告方式如下
: Const RAS_MAXENTRYNAME As Integer = 256
: Const RAS_MAXDEVICETYPE As Integer = 16
: Const RAS_MAXDEVICENAME As Integer = 128
: Const RAS_RASCONNSIZE As Integer = 412
: Const ERROR_SUCCESS = 0&
: 最后宣告几个型态及变数
: Private Type RasEntryName
: dwSize As Long
: szEntryName(RAS_MAXENTRYNAME) As Byte
: End Type

: Private Type RasConn
: dwSize As Long
: hRasConn As Long
: szEntryName(RAS_MAXENTRYNAME) As Byte
: szDeviceType(RAS_MAXDEVICETYPE) As Byte
: szDeviceName(RAS_MAXDEVICENAME) As Byte
: End Type

: Private StrISPName As String
: Private LngReturnCode As Long
: '若在模组宣告得去掉Private

: 之后提供你一些程式
: Public Sub Doup()
: Dim i As Long
: Dim lpRasConn(255) As RasConn
: Dim lpcb As Long
: Dim lpcConnections As Long
: Dim hRasConn As Long
: lpRasConn(0).dwSize = RAS_RASCONNSIZE
: lpcb = RAS_MAXENTRYNAME * _
: lpRasConn(0).dwSize

: lpcConnections = 0
: LngReturnCode = RasEnumConnections( _
: lpRasConn(0), lpcb, _
: lpcConnections)

: If LngReturnCode = ERROR_SUCCESS Then
: For i = 0 To lpcConnections - 1
: If Trim(ByteToString( _
: lpRasConn(i).szEntryName)) _
: = Trim(StrISPName) Then
: hRasConn = lpRasConn(i).hRasConn
: LngReturnCode = RasHangUp( _
: ByVal hRasConn)
: End If
: Next i
: End If

: End Sub
: 使用方法只要用
: Call Doup
: 就好了

请问ByteToString Funtion 该如何完成?

Follow Ups:

- Re: 我只会开,不会关ㄝ,怎么办.... Honey 18:14:32 11/23/98 (1)
  - 嘿嘿~~我比较天....^^ simon 23:10:41 11/24/98 (0)