:)
I want to create a dial up networking utility in VB6. Can some one guide me on the matter?
Printable View
:)
I want to create a dial up networking utility in VB6. Can some one guide me on the matter?
What exactly do you want?
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.
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?
Terminate what?
The existing connection or your program?
The existing connection. Sorry for the ambiguity.Quote:
Originally Posted by Hack
Will your app be accessing the same modem and therefore the same port as the existing connection?Quote:
Originally Posted by svg3414
The same modem.Quote:
Originally Posted by CDRIVE
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).
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:Quote:
Originally Posted by svg3414
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.
For no. 4 will this help?
Quote:
Originally Posted by dee-u
Does not seem to work. The connection remains active. There is no error message either. :confused: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
What does lResult returns?
What is the Windows TitleName or EXE name of your currently active dialup app? Is it visible in the Task bar when running?
Just pull the plug lol
The API should be working. If not you can use thge GetLastError API for more info.
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:Quote:
Originally Posted by CDRIVE
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
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. :confused:Quote:
Originally Posted by RobDog888
Me neither but who knows what his code is actually doing
Did you mean the InternetAutodialHangup API? If yes then this is from MSDN.Quote:
Originally Posted by CDRIVE
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.Quote:
Originally Posted by RobDog888
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..Quote:
Originally Posted by dee-u
"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.
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.
Upon googling I came across this, I supposed it should work without concerning the Automatic part.
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.Quote:
Originally Posted by RobDog888
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.Quote:
Originally Posted by CDRIVE
EDIT:
I guess the OP could be initiating the connection.Quote:
Originally Posted by svg3414
If you have a Dial-up connection could you try the link I have posted in post #24?
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?
This would have been best to have posted in post #1 ;)
If its not initiated by you then by who?
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.Quote:
Originally Posted by dee-u
Dee-U, you have my sincere Apologies for not being explicit! :o
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?Quote:
Originally Posted by RobDog888
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.Quote:
Originally Posted by RobDog888
This and other RasDial related API's are a wonderful find for those that play with MSComm. Great job Rob!!:thumb:
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
It works. This is exactly what I wanted. Thanks CDRIVE.Quote:
Originally Posted by CDRIVE
deeu, your posts were also helpful. thanks a lot.
Best of luck!!Quote:
Originally Posted by svg3414
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. :)
Thanks CDrive for reading my post #3 :DQuote:
Originally Posted by CDRIVE
Thanks for providing the code example ;)
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.