So now how do you connect to the ISP of the EU if they are not connected to do your things? Easy just go back to your oh faithful WinInet API.
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA"
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String,
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetAttemptConnect Lib "WinInet" (ByVal dwReserved
As Long) As Long
Const scUserAgent = "WinInet Example"
Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Public Function ConnectToISP() As Boolean
If InternetAttemptConnect(0) <> 0 Then Exit Function
If InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString,
vbNullString, 0) = 0 Then ConnectToISP = False Else ConnectToISP = True
End Function
How about hanging Up the darn modem? Yep you guessed it... back to the WinInet API.
Private Declare Function InternetAutodialHangup Lib "wininet.dll"
(ByVal dwReserved_ As Long) As Long
Public Function HangUpModem() As Boolean
If InternetAutodialHangup(0&) = 0 Then HangUpModem
= False Else HangUpModem = True
End Function
There! Three functions you'll need if you are wanting to make an internet related application which may require you to connect/disconnect and check the status of hte connection to continue.
Remember to use the Windows API as much as possible when checking for stuff related to the system. Not only is it faster but its most likely easier for you as the developer to use the API function than searching Registry Keys or other things. Next time around I'll show you how to get some information about the Dialup Networking Connection. I've attached a VB6 project so you can add that module to your projects. If your a VB5 user open the .VBP file in Notepad and remove the 'Retained' key.
Comments