Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

[247] Disconnect from the Internet

Last post 03-23-2005 11:53 PM by illuminati1618. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [247] Disconnect from the Internet

    This thread is for discussions of Disconnect from the Internet.

    • Post Points: 0
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 07-03-2002 3:25 AM In reply to

    Cannot Work 4 me

    It cannot work for me. I cannot disconnect my internet connection.
    • Post Points: 0
  • 07-03-2002 5:28 AM In reply to

    No offence to the kool Mr Crowley but tuhsan has written a Tutorial which you may be interested in:

    http://www.developerfusion.com/show/1920/3/ [Connecting/Disconnecting]

    http://www.developerfusion.com/show/1920/ [Using the WinInet API - Part I]

    I've found its easier and smaller code than Jame's!

    Happy [dis]connecting!
    • Post Points: 0
  • 07-25-2004 12:32 PM In reply to

    My dilapitated connection thanks you

    Aside from ERROR_SUCCESS not being defined (const ERROR_SUCCESS = 0), this code was exactly what I was after, and it allows me to extract information about active connections that I didn't think could be extracted.

    Thanks for posting it.
    • Post Points: 0
  • 10-25-2004 8:54 PM In reply to

    what happend in VB.Net

    First thanks for your code.
    I'm in trouple with this proplem - API RASConnections.
    You know, your code write in Vb6 and a convert it into VB.Net but the result not perfect, when I debug I realize the return of Error code is 87, and I don't know while - I found it in file RasError.h, but I could find anything about this Error code?? Pls help me !!!
    Here is my code in VB.Net

       'Module Code
       Public Structure RasEntryName
           Dim dwSize As Long
           Dim szEntryName() As Byte

           Public Sub init()
               ReDim szEntryName(RAS_MaxEntryName)
           End Sub
       End Structure

       Public Structure RasConn
           Dim dwSize As Long
           Dim hRasConn As Long
           Dim szEntryName() As Byte
           Dim szDeviceType() As Byte
           Dim szDeviceName() As Byte

           Public Sub init()
               ReDim szEntryName(RAS_MaxEntryName)
               ReDim szDeviceType(RAS_MaxDeviceType)
               ReDim szDeviceName(RAS_MaxDeviceName)
           End Sub
       End Structure

       Public Declare Function RasEnumConnections Lib _
       "rasapi32.dll" Alias "RasEnumConnectionsA" (ByVal lpRasConn As _
       RasConn, ByVal lpcb As Long, ByVal lpcConnections As Long) As Long

       Public Declare Function RasHangUp Lib "rasapi32.dll" Alias _
       "RasHangUpA" (ByVal hRasConn As Long) As Long
       Public gstrISPName As String
       Public ReturnCode As Long

       Public Sub HangUp()
           Dim i As Long
           Dim lpRasConn(255) As RasConn
           For i = 0 To 255
               lpRasConn(i).init()
           Next
           i = 0
           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
           ReturnCode = RasEnumConnections(lpRasConn(0), lpcb, _
           lpcConnections)

           If ReturnCode = ERROR_SUCCESS Then
               For i = 0 To lpcConnections - 1
                   If Trim(ByteToString(lpRasConn(i).szEntryName)) = Trim(gstrISPName) Then
                       hRasConn = lpRasConn(i).hRasConn
                       ReturnCode = RasHangUp(hRasConn)
                   End If
               Next i
           End If
       End Sub

       Public Function ByteToString(ByVal bytString() As Byte) As String
           Dim i As Integer
           ByteToString = ""
           i = 0
           While bytString(i) = 0&
               ByteToString = ByteToString & Chr(bytString(i))
               i = i + 1
           End While
       End Function

       Public Sub getConnections()
           Call HangUp()
       End Sub
    • Post Points: 0
  • 02-14-2005 9:15 AM In reply to

    • jeikul
    • Not Ranked
    • Joined on 10-19-2002
    • New Member
    • Points 5
    I got the same problem, anybody can help ?
    • Post Points: 0
  • 03-23-2005 11:53 PM In reply to

    I am getting the same problem , Please Help.. Did  anyone found a solution yet
    • Post Points: 0
Page 1 of 1 (7 items)