Closing dial up connection automatically 
Author Message
 Closing dial up connection automatically

We're using Wininet.dll to do some file transfers. When the transfers are
completed IF the user is on a dialup connection we would like to be able to
automatically close his connection so that it can be used again by another
app. If he is on a permanent connection (ISDN, T1 , Cable modem or ADSL, we
don't want to do this obviously :-)

Is there any place I could find code samples to do this?
Thanks.

--
Robert Dufour, MCP, MCT
President SGI IMS Inc.
www.sgiims.com



Mon, 28 Oct 2002 03:00:00 GMT  
 Closing dial up connection automatically
Try http://www.totalenviro.com/PlatformVB it solved my problems using RAS
Not sure about the Permanent Connection thingy, I have only used this using
Dial-up Networking and it definately works for that

Brian Corbett


Quote:
> We're using Wininet.dll to do some file transfers. When the transfers are
> completed IF the user is on a dialup connection we would like to be able
to
> automatically close his connection so that it can be used again by another
> app. If he is on a permanent connection (ISDN, T1 , Cable modem or ADSL,
we
> don't want to do this obviously :-)

> Is there any place I could find code samples to do this?
> Thanks.

> --
> Robert Dufour, MCP, MCT
> President SGI IMS Inc.
> www.sgiims.com



Mon, 28 Oct 2002 03:00:00 GMT  
 Closing dial up connection automatically
Here is what you need.  It will allow you to monitor the connection with the
isconnected sub and will allow to disconnect the user with the disconnect
sub.  It will only effect the dial-up connection and does not disrupt
LANorDSL.

Option Explicit
Public Declare Function RasEnumConnections Lib "RasApi32.dll" Alias
"RasEnumConnectionsA" (lpRasCon As Any, lpcb As Long, lpcConnections As
Long) As Long
Public Declare Function RasGetConnectStatus Lib "RasApi32.dll" Alias
"RasGetConnectStatusA" (ByVal hRasCon As Long, lpStatus As Any) As Long
Public Declare Function RasHangUp Lib "RasApi32.dll" Alias "RasHangUpA"
(ByVal hRasConn As Long) 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 Sub DisConnect()
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 "Error " & Err & " Has Occured!", vbOKOnly + vbCritical, "Error!"
    Exit Sub
End If

RasHangUp (TRasCon(0).hRasCon)

End Sub

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 "Error " & Err & " Has Occured!", vbOKOnly + vbCritical, "Error!"
    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


Quote:
> Try http://www.totalenviro.com/PlatformVB it solved my problems using RAS
> Not sure about the Permanent Connection thingy, I have only used this
using
> Dial-up Networking and it definately works for that

> Brian Corbett



> > We're using Wininet.dll to do some file transfers. When the transfers
are
> > completed IF the user is on a dialup connection we would like to be able
> to
> > automatically close his connection so that it can be used again by
another
> > app. If he is on a permanent connection (ISDN, T1 , Cable modem or ADSL,
> we
> > don't want to do this obviously :-)

> > Is there any place I could find code samples to do this?
> > Thanks.

> > --
> > Robert Dufour, MCP, MCT
> > President SGI IMS Inc.
> > www.sgiims.com



Tue, 29 Oct 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Automatically dialing a Dial-Up Networking connection

2. HOw to create automatically ras phone entry and dial the connection also

3. Closing a Dial up Networking Connection

4. Closing a dial-up connection

5. help: Closing Dial-up Connection

6. Q: how to close dial-up networking connection?

7. Closing a Dial up Networking Connection?

8. How to close Dial-up connection?

9. Closing a Dial-Up Connection

10. Callling and Closing the dial- up connection

11. Closing active Dial-Up Networking connection?

12. Dial Ups

 

 
Powered by phpBB® Forum Software