Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Disconnecting Dial Up Network

Posted on 1998-08-04
2
Medium Priority
?
164 Views
Last Modified: 2010-05-03
How can I disconnecting an internet connection WITHOUT running DUN and send key?
0
Comment
Question by:fury
[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 14

Accepted Solution

by:
waty earned 100 total points
ID: 1467770
' *** disconnect from the internet using VB
Private Const RAS_MAXENTRYNAME As Integer = 256
Private Const RAS_MAXDEVICETYPE As Integer = 16
Private Const RAS_MAXDEVICENAME As Integer = 128
Private Const RAS_RASCONNSIZE As Integer = 412

Private Type RasEntryName
    dwSize                          As Long
    szEntryName(RAS_MAXENTRYNAME)   As Byte
End Type

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 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

Public Sub HangUpConnection(sISPName As String)
   ' *** Disconnect from the internet using VB?
   ' *** If you want to terminate all connections to the internet using Visual Basic,
   ' *** you can use the Remote Access Services Hangup function.
   
   Dim i                As Long
   Dim lpRasConn(255)   As RasConn
   Dim lpcb             As Long
   Dim lpcConnections   As Long
   Dim hRasConn         As Long
   Dim nRet             As Long
   
   lpRasConn(0).dwSize = RAS_RASCONNSIZE
   lpcb = RAS_MAXENTRYNAME * lpRasConn(0).dwSize
   lpcConnections = 0
   nRet = RasEnumConnections(lpRasConn(0), lpcb, lpcConnections)
   
   If nRet = ERROR_SUCCESS Then
      For i = 0 To lpcConnections - 1
         If Trim(ByteToString(lpRasConn(i).szEntryName)) = Trim(sISPName) Then
            hRasConn = lpRasConn(i).hRasConn
            nRet = RASHangUp(ByVal hRasConn)
         End If
      Next
   End If

End Sub

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

0
 

Author Comment

by:fury
ID: 1467771
well..I know I am greedy :) Can I also have the code for the SENDKEY way....
Thanks a lot

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

618 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