![]() ![]() |
|
在VB程序中怎样挂断拨号网络 | |
作者:佚名 文章来源:不详 点击数 更新时间:2008/4/18 14:44:48 文章录入:杜斌 责任编辑:杜斌 | |
|
|
为了运行下面这个例子,首先需要建立一个窗体,在窗体上放置一个按钮,然后输入以下语句: Option Explicit 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 'set dwsize to 412 dwSize As Long hRasConn As Long szEntryName(RAS95_MaxEntryName) As Byte szDeviceType(RAS_MaxDeviceType) As Byte szDeviceName(RAS95_MaxDeviceName) As Byte End Type Private Sub Command1_Click() 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 Else MsgBox "没有拨号网络连接!", vbInformation End If End If End Sub 运行时,按下按钮就可以断开拨号网络的连接。 |
|
![]() ![]() |