|
-
Jan 9th, 2002, 08:11 AM
#1
Thread Starter
Junior Member
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
-
Jan 9th, 2002, 08:16 AM
#2
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:
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 Form_Load()
'KPD-Team 1998
'URL: [url]http://www.allapi.net/[/url]
'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
'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
If Trim(CStr(lpRasConn(i).szEntryName)) = Trim(gstrispname) Then
hRasConn = lpRasConn(i).hRasConn
'Hang up
returncode = RasHangUp(ByVal hRasConn)
End If
Next i
End If
End Sub
-
Jan 9th, 2002, 08:25 AM
#3
Thread Starter
Junior Member
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!!!
-
Jan 9th, 2002, 08:35 AM
#4
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!)
-
Jan 9th, 2002, 08:39 AM
#5
Thread Starter
Junior Member
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....
-
Jan 9th, 2002, 08:42 AM
#6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|