在VB程序中怎样挂断拨号网络
今天图老师小编要向大家分享个在VB程序中怎样挂断拨号网络教程,过程简单易学,相信聪明的你一定能轻松get!
为了运行下面这个例子,首先需要建立一个窗体,在窗体上放置一个按钮,然后输入以下语句:
OptionExplicit
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
'setdwsizeto412
dwSizeAsLong
hRasConnAsLong
szEntryName(RAS95_MaxEntryName)AsByte
szDeviceType(RAS_MaxDeviceType)AsByte
szDeviceName(RAS95_MaxDeviceName)AsByte
EndType
PrivateSubCommand1_Click()
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
IflpcConnections0Then
ForintLooper=0TolpcConnections-1
RasHangUplprasconn95(intLooper).hRasConn
NextintLooper
Else
MsgBox"没有拨号网络连接!",vbInformation
EndIf
EndIf
EndSub
运行时,按下按钮就可以断开拨号网络的连接。->