Results 1 to 6 of 6

Thread: modem disconnect

Hybrid View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Location
    Albany, New York
    Posts
    30

    Question modem disconnect

    Hi all -

    I've done a search for my topic - but I haven't found exactly what I am looking for. My question is can you disconnect a modem programmatically?

    What I have is an application that has a web browser front end for a weather information system. The end user first dials into a web server using a laptop or desktop, the web server accesses a database server through a LAN which stores road and weather info. What we want is to time out certain users so they don't tie up the phone line. We can time them out of the front end, but we want to disconnect their modem. Some users would tend to "turn the thing on, and walk away", which we are looking to avoid. Is there anyway to kick off their modem? The OS is at a minimum WinNT 4.0
    We were told that because of the web browser, there would be no way to kick them off the phone line, short of mechanically doing so. Which would entail us setting the disconnects on a ton of laptops, which could be a logistic nightmare.

    Any help, or suggestions for the programmer to try would be greatly appreciated.. as I don't have enough experience to know how to handle this if possible.

    Thanks much,
    Theresa

  2. #2
    Si_the_geek
    Guest
    This disconnects all dial-up connections, you could modify this to check the names of connections first (so that if there are multiple connections running, only the appropriate one is closed)
    VB Code:
    1. Const RAS_MAXENTRYNAME = 256
    2. Const RAS_MAXDEVICETYPE = 16
    3. Const RAS_MAXDEVICENAME = 128
    4. Const RAS_RASCONNSIZE = 412
    5. Private Type RasConn
    6.     dwSize As Long
    7.     hRasConn As Long
    8.     szEntryName(RAS_MAXENTRYNAME) As Byte
    9.     szDeviceType(RAS_MAXDEVICETYPE) As Byte
    10.     szDeviceName(RAS_MAXDEVICENAME) As Byte
    11. End Type
    12. Private Declare Function RasEnumConnections Lib "rasapi32.dll" Alias "RasEnumConnectionsA" (lpRasConn As Any, lpcb As Long, lpcConnections As Long) As Long
    13. Private Declare Function RasHangUp Lib "rasapi32.dll" Alias "RasHangUpA" (ByVal hRasConn As Long) As Long
    14. Private Sub Form_Load()
    15.     'KPD-Team 1998
    16.     'URL: [url]http://www.allapi.net/[/url]
    17.     'E-Mail: [email][email protected][/email]
    18.     'This program will close your Internet-connection, so to test this, you will have to open an Internet-connection.
    19.     Dim i As Long, lpRasConn(255) As RasConn, lpcb As Long
    20.     Dim lpcConnections As Long, hRasConn As Long
    21.     'Set the structure's size
    22.     lpRasConn(0).dwSize = RAS_RASCONNSIZE
    23.     lpcb = RAS_MAXENTRYNAME * lpRasConn(0).dwSize
    24.     lpcConnections = 0
    25.     'Enumerate all the available connections
    26.     returncode = RasEnumConnections(lpRasConn(0), lpcb, lpcConnections)
    27.  
    28.     If returncode = 0 Then
    29.         For i = 0 To lpcConnections - 1
    30.             If Trim(CStr(lpRasConn(i).szEntryName)) = Trim(gstrispname) Then
    31.                 hRasConn = lpRasConn(i).hRasConn
    32.                 'Hang up
    33.                 returncode = RasHangUp(ByVal hRasConn)
    34.             End If
    35.         Next i
    36.     End If
    37. End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Location
    Albany, New York
    Posts
    30
    Wow - thanks..... I never would have gotten that....

    Let me see if I understand completely.....

    If I want to disconnect the user after, say 10 minutes, the front end app would time the 10 minutes, then kick off this code that was put into a vb executable??? I'm not entirely sure if the app is written in vb, but I'm assuming I can call an exe from the app, or should this be started at system login ???

    Sorry I didn't put that in at first. But this would be the developers task to incorporate.....

    Thanks again!!!

  4. #4
    Si_the_geek
    Guest
    your first assumption is correct - just run the code after your 10 minutes (or however long you want) after the connection was started. you can have this code in a separate app or in the original (if it is in vb).

    Of course this is assuming that the connection isn't being used, if it is you should really reset the timer before this code is run (how/if you can do that depends on what your program does already!)

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Location
    Albany, New York
    Posts
    30
    The connection should only be used at the time the user starts the app... but the test is a good idea...

    Thanks much for your help Si_the_geek - it is greatly appreciated....

  6. #6
    Si_the_geek
    Guest

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