Results 1 to 36 of 36

Thread: [RESOLVED] Dial up networking

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Resolved [RESOLVED] Dial up networking



    I want to create a dial up networking utility in VB6. Can some one guide me on the matter?

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Dial up networking

    What exactly do you want?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Dial up networking

    Do you want Dial Up connections or VPNs?

    Shelling the rasdial.exe in the system32 directory wil only get you so far depending upon your needs.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Dial up networking

    It is Dialup connection to the internet.

    I have downloaded some code and am working on it.

    The dialing part is OK. And once the connection is established I am also able
    to terminate the connection.

    But my problem now is this:

    If the system is already connected to the internet (before my application loads), I want my application to terminate it. How can I do that?

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Dial up networking

    Terminate what?

    The existing connection or your program?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Dial up networking

    Quote Originally Posted by Hack
    Terminate what?

    The existing connection or your program?
    The existing connection. Sorry for the ambiguity.

  7. #7
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Dial up networking

    Quote Originally Posted by svg3414
    The existing connection. Sorry for the ambiguity.
    Will your app be accessing the same modem and therefore the same port as the existing connection?
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Dial up networking

    Quote Originally Posted by CDRIVE
    Will your app be accessing the same modem and therefore the same port as the existing connection?
    The same modem.

    I will clarify a bit.

    This is for an application to be installed at the branches of my company.
    The system at the branches generate periodical reports which are saved to a particular folder. These files have to be sent to a particular email address. What my application does is.

    1. See whether there are any files for sending.
    2. See whether the dial up connection is active. If no, dial the connection else skip to step 3.
    3. Send these files.
    4. Close the connection.

    Upto step 3 it is working OK.

    In step 4, I dont know how to close a pre-existing connection (connection that was not established in step 2 but was already active).

  9. #9
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Dial up networking

    Quote Originally Posted by svg3414
    The same modem.

    What my application does is.

    1. See whether there are any files for sending.
    2. See whether the dial up connection is active. If no, dial the connection else skip to step 3.
    3. Send these files.
    4. Close the connection.

    Upto step 3 it is working OK.

    In step 4, I dont know how to close a pre-existing connection (connection that was not established in step 2 but was already active).
    Well killing a process or an app by Title Name & or EXE name and even Process ID has been posted in the forum many times and should be easy to find with a forum search for:

    Kill
    KillProcess
    "Kill Process"
    TerminateProcess
    "Terminate Process"
    TerminateByTitle
    "Terminate By Title"

    I don't think killing the process or closing an app is going to be much of a problem. The problem is going to be killing it gracefully, as the previous process could be sending or receiving data when you kill it.
    Last edited by CDRIVE; Dec 31st, 2008 at 11:18 AM. Reason: trim quote
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  10. #10
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Dial up networking

    For no. 4 will this help?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Dial up networking

    Quote Originally Posted by dee-u
    For no. 4 will this help?

    Code:
    Const Internet_Autodial_Force_Unattended As Long = 2
    Public Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
    Public 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
    Does not seem to work. The connection remains active. There is no error message either.

  12. #12
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Dial up networking

    What does lResult returns?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  13. #13
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Dial up networking

    What is the Windows TitleName or EXE name of your currently active dialup app? Is it visible in the Task bar when running?
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Dial up networking

    Just pull the plug lol

    The API should be working. If not you can use thge GetLastError API for more info.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Dial up networking

    Evidently you did not do a search as suggested. TerminateByTitle will close an app by referencing its Title bar name (no file extension). I've tested this code and it works, even if the Title named app is minimized.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  16. #16
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Dial up networking

    Quote Originally Posted by CDRIVE
    Evidently you did not do a search as suggested. TerminateByTitle will close an app by referencing its Title bar name (no file extension). I've tested this code and it works, even if the Title named app is minimized.
    In the event that you're not certain how to call this function, do it like this:

    Code:
    Option Explicit
    
    Private Sub Command1_Click()
      Dim strAppTitle As String
    'Call with
          strAppTitle = "Dialup Networking"    ' must be exactly formatted as seen in the Title bar.
    
       CloseProgram (strAppTitle)
    End Sub
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  17. #17
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Dial up networking

    Seems like you shouldnt have to terminate the process in order to hang up the connection. Do you have something using it still that could be holding it open?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  18. #18
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Dial up networking

    Quote Originally Posted by RobDog888
    Seems like you shouldnt have to terminate the process in order to hang up the connection. Do you have something using it still that could be holding it open?
    Please explain to me how those API's work because I don't see anything in them that would send an AT Command to the modem to put it ON HOOK.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  19. #19
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Dial up networking

    Me neither but who knows what his code is actually doing
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  20. #20
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Dial up networking

    Quote Originally Posted by CDRIVE
    Please explain to me how those API's work because I don't see anything in them that would send an AT Command to the modem to put it ON HOOK.
    Did you mean the InternetAutodialHangup API? If yes then this is from MSDN.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  21. #21
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Dial up networking

    Quote Originally Posted by RobDog888
    Me neither but who knows what his code is actually doing
    Well the last time I used dialup on this XP machine was during Hurricane Wilma, while it lasted! Anyway, unlike W98, that has Dialup Networking in the Accessories directory, XP has only Hyper Term. Dialup is accessed through a "Connect To" shortcut on the Start menu. When I connected with it I was surprised to not find a new process running in a Processes Running app that I have. Also the code that I linked to only closed the "Connection Status" window and didn't disconnect.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  22. #22
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Dial up networking

    Quote Originally Posted by dee-u
    Did you mean the InternetAutodialHangup API? If yes then this is from MSDN.
    Yes, that's the API I was referring to. Is it possible that this API refers to an OptionButton found in IE that says: "Dial whenever a network connection is not present"? The reason I'm asking this is that the API at your link description states..
    "Disconnects an Automatic dial-up connection. The term automatic makes me question this. I'm assuming that the setting that I mentioned will automatically dial-up when IE is started if that OptButton is selected and no network connection is detected.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  23. #23
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Dial up networking

    I am not sure about that, cannot test since I don't have a DialUp connection. In any case there's also the InternetHangUp API.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  24. #24
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Dial up networking

    Upon googling I came across this, I supposed it should work without concerning the Automatic part.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  25. #25
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Dial up networking

    Quote Originally Posted by RobDog888
    Seems like you shouldnt have to terminate the process in order to hang up the connection. Do you have something using it still that could be holding it open?
    Yes, that's the point of this thread. The OP wants to access a Modem that's in use by another app. I think this is a dead end though. I think all those API's and links to API's by dee-u are misleading. My guess is that none of those API's will close a connection unless the VB app initiated the connection in the first place.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  26. #26
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Dial up networking

    Quote Originally Posted by CDRIVE
    Yes, that's the point of this thread. The OP wants to access a Modem that's in use by another app. I think this is a dead end though. I think all those API's and links to API's by dee-u are misleading. My guess is that none of those API's will close a connection unless the VB app initiated the connection in the first place.
    I don't intend to mislead people, I only offer probable solutions that could be tried, if they won't work then that does not mean I have mislead the OP.

    EDIT:
    Quote Originally Posted by svg3414
    2. See whether the dial up connection is active. If no, dial the connection else skip to step 3.
    I guess the OP could be initiating the connection.
    If you have a Dial-up connection could you try the link I have posted in post #24?
    Last edited by dee-u; Jan 1st, 2009 at 01:23 AM.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  27. #27

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Dial up networking

    I will be initiating the connection only if it is not already connected.

    If the connection is initiated by me, I am able to close it.

    My problem is I want to terminate the connection even if it is not initiated by me. Can I do that?

  28. #28
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Dial up networking

    This would have been best to have posted in post #1

    If its not initiated by you then by who?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  29. #29
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Dial up networking

    Quote Originally Posted by dee-u
    I don't intend to mislead people, I only offer probable solutions that could be tried, if they won't work then that does not mean I have mislead the OP.
    I certainly hope that you are the only member that misinterpreted that statement. Actually, I feel terrible that you interpreted that way. You did a magnificent job of providing links to possible solutions. I was referring to the information in the links. None of them alert the reader that their VB app must have initiated the connection.

    Dee-U, you have my sincere Apologies for not being explicit!
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  30. #30

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Dial up networking

    Quote Originally Posted by RobDog888
    This would have been best to have posted in post #1

    If its not initiated by you then by who?
    Suppose User A has initiated the connection for some purpose, say browsing the internet. After having served his purpose he forgets to terminate the connection. Now after some time he launches the application to send the reports (as mentioned earlier). After having send the reports the application must automatically terminate the connection. Is it possible?

  31. #31
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Unhappy Re: Dial up networking

    Quote Originally Posted by RobDog888
    Do you want Dial Up connections or VPNs?

    Shelling the rasdial.exe in the system32 directory wil only get you so far depending upon your needs.
    Rob, it's unfortunate that this post was overlooked. I read it this morning and have been reading as much as I could about RasDial since. I tested this code moments ago and it works!!! It scans for existing DialUp connections and closes them. The port and the modem are then free to be accessed by MSComm.

    This and other RasDial related API's are a wonderful find for those that play with MSComm. Great job Rob!!

    Code:
    Option Explicit
    
    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 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
    
        
    Private Sub Command1_Click()
    'KPD-Team 1998
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        'This program will close your Internet-connection, so to test this, you will have to open an Internet-connection.
        Dim i As Long, lpRasConn(255) As RasConn, lpcb As Long
        Dim lpcConnections As Long, hRasConn As Long
        Dim ReturnCode As Long
        'Set the structure's size
        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
          MsgBox "The Modem has hung up!"
        End If
    End Sub
    Last edited by CDRIVE; Jan 1st, 2009 at 09:29 PM. Reason: Changed 'ReturnCode' from Variant to Long
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  32. #32

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    Kerala, India
    Posts
    275

    Re: Dial up networking

    Quote Originally Posted by CDRIVE
    Rob, it's unfortunate that this post was overlooked. I read it this morning and have been reading as much as I could about RasDial since. I tested this code moments ago and it works!!! It scans for existing DialUp connections and closes them. The port and the modem are then free to be accessed by MSComm.

    This and other RasDial related API's are a wonderful find for those that play with MSComm. Great job Rob!!

    Code:
    Option Explicit
    
    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 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
    
        
    Private Sub Command1_Click()
    'KPD-Team 1998
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        'This program will close your Internet-connection, so to test this, you will have to open an Internet-connection.
        Dim i As Long, lpRasConn(255) As RasConn, lpcb As Long
        Dim lpcConnections As Long, hRasConn As Long
        Dim ReturnCode
        'Set the structure's size
        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
          MsgBox "The Modem has hung up!"
        End If
    End Sub
    It works. This is exactly what I wanted. Thanks CDRIVE.

    deeu, your posts were also helpful. thanks a lot.

  33. #33
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Dial up networking

    Quote Originally Posted by svg3414
    It works. This is exactly what I wanted. Thanks CDRIVE.

    deeu, your posts were also helpful. thanks a lot.
    Best of luck!!
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  34. #34
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: [RESOLVED] Dial up networking

    svg3414, I forgot to mention that if you need any help with your MSComm code interacting with these API's let me know. I'm guessing you're going to want MSComm to attempt a connection and prompt if the port is in use. Thus giving the user the option to execute the hang up or not. On the other hand, I guess you could always use the sawed off 12 ga. method and take priority control of the port and modem regardless.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  35. #35
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Dial up networking

    Quote Originally Posted by CDRIVE
    Rob, it's unfortunate that this post was overlooked. I read it this morning and have been reading as much as I could about RasDial since. I tested this code moments ago and it works!!! It scans for existing DialUp connections and closes them. The port and the modem are then free to be accessed by MSComm.

    This and other RasDial related API's are a wonderful find for those that play with MSComm. Great job Rob!!

    Code:
    Option Explicit
    
    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 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
    
        
    Private Sub Command1_Click()
    'KPD-Team 1998
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        'This program will close your Internet-connection, so to test this, you will have to open an Internet-connection.
        Dim i As Long, lpRasConn(255) As RasConn, lpcb As Long
        Dim lpcConnections As Long, hRasConn As Long
        Dim ReturnCode
        'Set the structure's size
        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
          MsgBox "The Modem has hung up!"
        End If
    End Sub
    Thanks CDrive for reading my post #3

    Thanks for providing the code example
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  36. #36
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: [RESOLVED] Dial up networking

    svg3414, please be advised that I modified the RasHangUp code. When that API was copied from the API Viewer the KDP Team had neglected to declare a variable, so I declared it as a variant, since I wasn't certain of what it should be. 'ReturnCode' is now declared as a Long as I believe it should be.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width