?
Solved

Close Internet Connection

Posted on 2003-11-14
2
Medium Priority
?
455 Views
Last Modified: 2008-02-01
Is there any api to close Internet connection in vb6? I tried to find it but unsuccessfully. I just want to click a button and then the program disconnects me from Internet. That's all.

this is all what I found:

Const Internet_Autodial_Force_Unattended As Long = 2
Private Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Private Declare Function InternetAutodialHangup Lib "wininet.dll" (ByVal dwReserved As Long) As Long

Private Sub Command1_Click()
Dim lResult As Long
lResult = InternetAutodialHangup(0&)
End Sub

but it didn't work. why? any other suggestions?
0
Comment
Question by:vbr666
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
RocketMan801 earned 216 total points
ID: 9748789
if the conections is a dial-up connection u can hang up by calling the RasHangUp api, here is an example of how it works (took from the API guide, the KDP team), copy and paste in a form:


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

Const RAS_MAXENTRYNAME = 256
Const RAS_MAXDEVICETYPE = 16
Const RAS_MAXDEVICENAME = 128
Const RAS_RASCONNSIZE = 412
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 Sub Form_Load()
    Dim i As Long, lpRasConn(255) As RasConn, lpcb As Long
    Dim lpcConnections As Long, hRasConn As Long
   

    lpRasConn(0).dwSize = RAS_RASCONNSIZE
    lpcb = RAS_MAXENTRYNAME * lpRasConn(0).dwSize
    lpcConnections = 0
   
    'Enumerate all the available connections
    returncode = RasEnumConnections(lpRasConn(0), lpcb, lpcConnections)

    If returncode = 0 Then
        For i = 0 To lpcConnections - 1
            hRasConn = lpRasConn(i).hRasConn
            'Hang up
            returncode = RasHangUp(ByVal hRasConn)
        Next i
    End If
End Sub
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 9748805
Try using the example at the bottom of this page instead:

http://www.mentalis.org/apilist/RasHangUp.shtml
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question